and [True,True] --> [True, True]?????
Peter Otten
__peter__ at web.de
Fri Apr 24 07:16:05 EDT 2009
Paul Rubin wrote:
> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
>> len() works on dicts and sets, and they're not sequences.
>
> Of course dicts and sets are sequences. But there are also sequences
> on which len doesn't work.
That was my intuition, too. But Python takes a different stance:
>>> from collections import *
>>> for obj in [(), [], {}, set()]:
... print(("%r: " % (obj,)) + ", ".join(a.__name__ for a in [Iterable,
Container, Sequence] if isinstance(obj, a)))
...
(): Iterable, Container, Sequence
[]: Iterable, Container, Sequence
{}: Iterable, Container
set(): Iterable, Container
Peter
More information about the Python-list
mailing list