Some language proposals.

Josiah Carlson jcarlson at nospam.uci.edu
Fri Mar 5 02:27:26 EST 2004


[snip classes not behaving like class instances]

I see.  You are not happy with the fact that instances of some other 
class, with a __call__ method are not considered a bound instance 
method.  I'm sure you have thought of it, but I would wrap it.  It may 
take another function call, but really, what other functionality do you 
need that the below does not provide?

Give the below a shot.

  - Josiah

class callee:
     def __call__(s, self, *args):
         print self

def instance(self, *args):
     print self

def wrapper(self, *args):
     print self
     self._c(self, *args)

class caller:
     pass

caller.instance_method = instance
caller.instance_method2 = wrapper
foo = caller()
caller._c = callee()

foo.instance_method()
foo.instance_method2()
foo.instance_method
foo.instance_method2



More information about the Python-list mailing list