Re: len() and PEP 3000

2006-12-09 Thread Ross Ridge
Colin J. Williams wrote: > __len__ is not very special and the > property len eliminates the redundant parentheses. tac-tics wrote: > One might say the current syntax eliminates the redundant dot. Make "len" an operator, like C's "sizeof", and eliminate the (hypothetical) dot, parenthesises and a

Re: len() and PEP 3000

2006-12-09 Thread Fredrik Lundh
Colin J. Williams wrote: > On the other hand, one can argue that, since len is intimately > associated with an object, it's better treated as an attribute/property > than to have an unconnected function out in namespace. "unconnected" ??? -- http://mail.python.org/mailman/listinfo/python-li

Re: len() and PEP 3000

2006-12-09 Thread Colin J. Williams
tac-tics wrote: >> __len__ is not very special and the >> property len eliminates the redundant parentheses. > > One might say the current syntax eliminates the redundant dot. > touché On the other hand, one can argue that, since len is intimately associated with an object, it's better treated

Re: len() and PEP 3000

2006-12-09 Thread tac-tics
> __len__ is not very special and the > property len eliminates the redundant parentheses. One might say the current syntax eliminates the redundant dot. -- http://mail.python.org/mailman/listinfo/python-list

Re: len() and PEP 3000

2006-12-09 Thread bearophileHUGS
Colin J. Williams: > 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. You mean something like: >>> "ab".len, [1, 2, 3].len (2, 3) In the given page Guido

Re: len() and PEP 3000

2006-12-09 Thread Colin J. Williams
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://e

Re: len() and PEP 3000

2006-12-07 Thread Giovanni Bajo
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-u

Re: len() and PEP 3000

2006-12-06 Thread Fredrik Lundh
Beliavsky wrote: > I agree with you -- a.__len__() is ugly compared to len(a) . I am > surprised that such common idioms as len(a) may be going away. no need to; the fact that something isn't currently mentioned in a preliminary Python 3000 PEP doesn't mean that it will be removed. -- http:/

Re: len() and PEP 3000

2006-12-06 Thread Klaas
Beliavsky wrote: > Thomas Guettler wrote: > > Hi, > > > > The function len() is not mentioned in the Python 3000 PEPs. > > > > I suggest that at least lists, tupples, sets, dictionaries and strings > > get a len() method. I think the len function can stay, removing it > > would break to much code.

Re: len() and PEP 3000

2006-12-06 Thread Beliavsky
Thomas Guettler wrote: > Hi, > > The function len() is not mentioned in the Python 3000 PEPs. > > I suggest that at least lists, tupples, sets, dictionaries and strings > get a len() method. I think the len function can stay, removing it > would break to much code. But adding the method, would bu u

Re: len() and PEP 3000

2006-12-06 Thread Bjoern Schliessmann
Kay Schluehr wrote: > Pro: Because it makes the API more monotonous and more aligned > with all other OO languages that exist now and in future. It also > helps any written and unwritten IDE providing a method by means of > autocompletion. It ends endless debates with Java/C++/C# etc. and > newbie

Re: len() and PEP 3000

2006-12-06 Thread Kay Schluehr
Bjoern Schliessmann schrieb: > Thomas Guettler wrote: > > > I suggest that at least lists, tupples, sets, dictionaries and > > strings get a len() method. > > Why? Pro: Because it makes the API more monotonous and more aligned with all other OO languages that exist now and in future. It also help

Re: len() and PEP 3000

2006-12-06 Thread Bjoern Schliessmann
Thomas Guettler wrote: > I suggest that at least lists, tupples, sets, dictionaries and > strings get a len() method. Why? > I think the len function can stay, removing it would break to much > code. But adding the method, would bu usefull. > > Yes, I know, that I can call .__len__() but that

len() and PEP 3000

2006-12-06 Thread Thomas Guettler
Hi, The function len() is not mentioned in the Python 3000 PEPs. I suggest that at least lists, tupples, sets, dictionaries and strings get a len() method. I think the len function can stay, removing it would break to much code. But adding the method, would bu usefull. Yes, I know, that I can ca