Paul Rubin wrote:

> Steven D'Aprano <st...@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
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to