Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tuples inside of str.startswith (for multiple checks) #122

Merged
merged 1 commit into from
Jul 28, 2017
Merged

Use tuples inside of str.startswith (for multiple checks) #122

merged 1 commit into from
Jul 28, 2017

Conversation

delirious-lettuce
Copy link
Contributor

I checked the .travis.yml file and it says the earliest Python version being checked is 2.6. I double-checked the docs and it looks like str.startswith has accepted tuples since 2.5.

Changed in version 2.5: Accept tuples as prefix.

>>> url = 's://'
>>> url.startswith('s://') or url.startswith('://')
True
>>> url.startswith(('s://', '://'))
True

>>> url = '://'
>>> url.startswith('s://') or url.startswith('://')
True
>>> url.startswith(('s://', '://'))
True

>>> url = 'www'
>>> not url.startswith('http://') and not url.startswith('https://')
True
>>> not url.startswith(('http://', 'https://'))
True

@eliangcs eliangcs merged commit f58a85f into httpie:master Jul 28, 2017
@eliangcs
Copy link
Contributor

Looks good, thanks!

@delirious-lettuce delirious-lettuce deleted the startswith_tuples branch July 28, 2017 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants