Confused with methods
John Lenton
john at grulic.org.ar
Mon Feb 7 09:49:35 EST 2005
On Mon, Feb 07, 2005 at 03:24:11PM +0100, Alex Martelli wrote:
> def always produces a
> function object and binds it to the name coming after keyword 'def'.
> Any such function object, no matter how produced and how bound hither
> and thither, always behaves in exactly the same way.
This isn't exactly true:
>>> class C(object):
... def __new__(*a): pass
...
>>> C.__new__
<function __new__ at 0x40088d4c>
>>> class D(object): pass
...
>>> def __new__(*a): pass
...
>>> D.__new__ = __new__
>>> D.__new__
<unbound method D.__new__>
of course, __new__ is special-cased (*some*body should've read "import
this", especially the part "explicit is better than implicit").
--
John Lenton (john at grulic.org.ar) -- Random fortune:
Al freír será el reír.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20050207/65f1c89c/attachment.sig>
More information about the Python-list
mailing list