On 6/13/06, Tim Peters <[EMAIL PROTECTED]> wrote:
> [georg.brandl]
> >> Author: georg.brandl
> >> Date: Fri Jun 9 20:45:48 2006
> >> New Revision: 46795
> >>
> >> Log:
> >> RFE #1491485: str/unicode.endswith()/startswith() now accept a
> tuple as first argument.
>
> [Neal Norwitz]
> > What's the reason to not support any sequence and only support tuples?
>
> It can't support any sequence, else e.g. s.endswith(".py") would be ambiguous.
Good point, I was really just thinking of lists though.
> > Are there any other APIs that only support tuples rather than all
> > sequences?
>
> Oh, who cares -- it would be a relief to leave _something_ simple <0.7
> wink>.
:-)
I was thinking about a use case like this:
supported_suffixes = ['.py', '.pyc', '.pyo']
if sys.platform[:3] == 'win':
supported_suffixes.append('.pyw')
if pathname.endswith(supported_suffixes):
# ...
I realize you could just throw a tuple(supported_suffixes). I don't
know that I've ever needed that specific use case. I don't think it's
too common. Just thinking about avoiding newbie surprises.
> Given that {start,end}swidth can't support all sequences regardless,
> restricting it to tuples is OK by me, and was clearly sufficient for
> the uses made of this already in the standard library.
I'm ok with this either way. It's easy enough to add later, but hard
to take away.
n
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com