chrisks at NOSPAM.udel.edu
Thu Oct 21 09:05:44 CEST 2004
Josiah Carlson wrote:
> Double underscore methods are considered "magic" methods. The
> underscores are a hint that they may do something different. Kind of
> like the C++ friend operators.
> In terms of .len() vs .__len__(), it is not supposed to be called
> directly by user code; __len__() is called indirectly by the len()
> builtin (and similarly for the other __<op>__() methods, check common
> spellings in the operator module).
I realize that. My point is why? Why is the default not object.len()?
The traditional object oriented way to access an object's attribute is
as object.attribute. For those that are truly attached to the antiquated
C-style notation, I see no reason why method(object) and object.method()
cannot exist side-by-side if need be. Using method(object) instead of
object.method() is a throwback from Python's earlier non-object oriented
days, and something which should be phased out by p3k. Personally, I'd
like to see the use of underscores in name-mangling thrown out
altogether, as they "uglify" certain code and have no practical use in a
truly OO language, but I'm sure that's a point many will disagree with
More information about the Python-list