Range Operation pre-PEP
Tim Peters
tim.one at home.com
Fri May 11 14:49:39 EDT 2001
[Fredrik Lundh]
> ...
> like most other operations that work on sequences, min() and max()
> only require you to have working __len__ and __getitem__ methods.
You won't need either in 2.2: it will be enough that the min()/max()
argument be iterable. For an extreme example, max(sys.stdin) (btw, this
stuff already works in current CVS Python).
[Douglas Alan, on filter()]
>> Yes, if its sequence argument is a tuple, then it returns a tuple
[back to /F]
> which probably is an unfortunate oversight, since it returns lists
> for all other sequences:
Not quite. It also special-cases the snot out of strings:
>>> filter(lambda ch: ch in 'aeiou', "It also special-cases the "
... "snot out of strings.")
'aoeiaaeeoouoi'
>>>
Oops: make that 8-bit strings. Pass filter() a Unicode string instead, and
then it returns a list -- oh ya, *that's* Pythonic <wink>.
The tuple and 8-bit string special-casing in filter() aren't oversights,
they're deliberate warts in the code. Although I'd agree to call the
existence of these warts an oversight in the patch review process ...
stuck-with-it-now-ly y'rs - tim
More information about the Python-list
mailing list