Simplify your code using a tuple in str.startswith() 🚀
Did you know that you can use a tuple of strings as an argument in the startswith() method?
See a quick refactoring below. With just one line, you can check for multiple prefixes. 🌟
This makes your code cleaner 😍 📈
def is_url(path):
return path.startswith('http://') \
or path.startswith('https://') \
or path.startswith('ftp://')
# refactored
def is_url(path):
return path.startswith(('http://', 'https://', 'ftp://'))
#strings