Some language proposals.

Josiah Carlson jcarlson at nospam.uci.edu
Sat Feb 28 22:38:47 EST 2004


>>class Callable:
>>    def __call__(self):
>>        print "!"
>>
>>class C:
>>    def __init__(self):
>>        self.foo = Callable()
>>
>>C().foo()
>>
>>Now tell me why this doesn't do what you want.
> 
> 
> Because
> 
> 
>>>>C.foo
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: class C has no attribute 'foo'
> 
> for a start.

Perhaps you want the below.  You seem to be interested in doing things 
with classes and not instances.

class Callable:
     def __call__(self):
         print "!"

class C:
     foo = Callable()

  - Josiah



More information about the Python-list mailing list