len() and __len__
Greg Ewing
look at replyto.address.invalid
Mon May 27 01:06:21 EDT 2002
Pete Shinners wrote:
>
> len() will work on any type of sequence object (lists, tuples, and all).
> __len__ will only work on class instances with a __len__ method.
I think that, in Python 2.2, any object which responds
to len() also appears to have a __len__ method, due to
some magic which has been added to support subclassing
of builtin types.
---
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list