A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-March/062072.html below:

[Python-Dev] .len() instead of __len__() (was: iterator API in Py3.0)

[Python-Dev] .len() instead of __len__() (was: iterator API in Py3.0) [Python-Dev] .len() instead of __len__() (was: iterator API in Py3.0)Oleg Broytmann phd at mail2.phd.pp.ru
Sun Mar 5 15:44:17 CET 2006
Hello!

On Sat, Mar 04, 2006 at 04:31:26PM -0500, Phillip J. Eby wrote:
> I'm not sure that "more object-oriented" should be equated with "good" in 
> this context, or indeed any context. :)

   I am sure it is.

> A function is no more or less 
> polymorphic than a method in any case, especially if the function is 
> normally delegating to a slot or special method in any case.

   Advantages of a method over a function:

-- a method is a more natural way to query or manipulate objects;
-- a direct method call is faster than two-level call (len() => .__len__());
-- unnecessary cluttering of builtin namespace; the namespace should(1)
   contains only really global functions (__import__(), eval(), etc.)

   What are the advantages of a function over a method? What are
disadvantages of a direct .len() instead of .__len__()?

Footnote:

(1) I am a perfectionist and I partially disagree with "practicality beats
purity"; I would really love a small uncluttered builtin namespace in
Python.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4