Message54805
In the same way that exceptions can have a tuple of
types specified and isinstance can take a tuple of
types, str.startswith and endswith could take a tuple
of possible prefixes/suffixes.
One use-case::
if filename.endswith(('jpg', 'gif', 'png')):
# ...
vs:
if (filename.endswith('jpg') or filename.endswith
('gif') or
filename.endswith('png')):
#...
Obviously it's not a huge improvement in clarity, but
it does seem to be an improvement to me.
|
|
Date |
User |
Action |
Args |
2007-08-23 16:11:55 | admin | link | issue1491485 messages |
2007-08-23 16:11:55 | admin | create | |
|