On Jul 20, 2006, at 3:26 AM, Greg Ewing wrote:

> Ronald Oussoren wrote:
>
>> Classic classes?
>
> I just checked, and it seems they've been fixed too:
> callable() and hasattr(obj, '__call_') give the same
> result -- true if and only if a __call__ method has
> been defined.

But classic classes theirself are callable yet don't have a __call__  
attribute. New-style classes do have a call method. To expand on my  
previous interpreter session:

Python 2.5b2 (r25b2:50570, Jul 11 2006, 09:46:24)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> class O: pass        # Old-style class
...
 >>> O.__call__             # No __call__
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: class O has no attribute '__call__'
 >>> class N (object): pass      # New-style class
...
 >>> N.__call__             # Has __call__
<method-wrapper '__call__' of type object at 0x60f770>
 >>>
 >>> # Instantition by calling works for both:
 >>> O()
<__main__.O instance at 0x701c0>
 >>> N()
<__main__.N object at 0x6e410>
 >>>


Ronald

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to