__call__ question

Rick r.l.richardson at verizon.net
Mon Sep 30 18:50:55 EDT 2002

If I generate a call method inside a class class with def __call__(self, 
arg1): ...
everything is hunkey dorey.  

However if I generate the class then later try to add the __call__ 
function with setattribute or by create a function that behaves like 
call should and then assigning it to myobj.__class__ I can't call the 
instance of the class like a callable object. It states that that 
instance is not a callable object. I can however:

myobj.__call__(myobj, arg1)
and it works. Anyone know what I have to do to make an object callable 
at runtime?


Rick Richardson

More information about the Python-list mailing list