samwyse a écrit :
On Jul 8, 4:56 pm, Joseph Barillari <[EMAIL PROTECTED]> wrote:

My question is: did something about the way the special method names are
implemented change for new-style classes?

Just off the top of my head, I'd guess that it's due to classes
already having a default __call__ method,

>>> object.__dict__.keys()
['__setattr__', '__reduce_ex__', '__new__', '__reduce__', '__str__', '__getattribute__', '__class__', '__delattr__', '__repr__', '__hash__', '__doc__', '__init__']

No __call__ method here.

used when you instatiate.

The __call__ method used to instanciate a class is actually the metaclass __call__ method.

>>> class MyType(type):
...     def __call__(self, *args, **kw):
...         print "pikaboo"
...         return type.__call__(self, *args, **kw)
...
>>> class MyClass(object):
...     __metaclass__ = MyType
...
>>> MyClass()
pikaboo
<__main__.MyClass object at 0x8334eec>
>>>


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to