[BangPypers] Truth Tests (bool)
noufal at nibrahim.net.in
Fri Jan 13 19:50:11 CET 2012
Sreenivas Reddy T <thatiparthysreenivas at gmail.com> writes:
> I would like to clear things here.I am assuming beginner as a common
> denominator to this post.
> 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
Honk if you are against noise pollution!
More information about the BangPypers