httpie / http-prompt

An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
https://http-prompt.com
MIT License
8.96k stars 326 forks source link

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

Closed delirious-lettuce closed 7 years ago

delirious-lettuce commented 7 years ago

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 commented 7 years ago

Looks good, thanks!