len() and PEP 3000

Colin J. Williams cjw at sympatico.ca
Sat Dec 9 11:37:51 EST 2006


Giovanni Bajo wrote:
> Thomas Guettler wrote:
> 
>> I have read the FAQ to the len function:
>> http://www.python.org/doc/faq/general/#why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list
> 
> Outdated. You want to read the new FAQ, here:
> http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm

Why not replace the __len__ method with a len property for strings, 
lists, tuples, dictionaries etc.  __len__ is not very special and the 
property len eliminates the redundant parentheses.

Colin W.




More information about the Python-list mailing list