[BangPypers] Truth Tests (bool)
Senthil Kumaran
senthil at uthcode.com
Sat Jan 14 00:49:10 CET 2012
On Sat, Jan 14, 2012 at 12:20:11AM +0530, Noufal Ibrahim wrote:
> > len() method is just a shortcut to __len__ magic method .So when you
> > call len() on your own container type ,it does not traverse whole
> > sequence ,it just calls __len__ method and returns value(assume
> > self.size=0 in constructor) from this method.This value incremented or
> > decremented in add and remove method on your container type.
>
> This is an interesting point especially with Python3 returning something
> other than lists for things like dict.keys. I'll dig into this a
> little.
Yeah, dict view or in general the concept of memoryview, but they do
have len().
--
Senthil
More information about the BangPypers
mailing list