First of all, please don't flame me immediately. I did browse archives
and didn't see any solution to my problem.

Assume I want to add a method to an object at runtime. Yes, to an
object, not a class - because changing a class would have global
effects and I want to alter a particular object only. The following
approach fails:

class kla:
    x = 1

def foo(self):
    print self.x

k = kla()
k.foo = foo
k.foo()

I know where the problem is. The method shouldn't have 'self'
parameter. But how do I access object's attributes without it?

Best regards,

Marek

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

Reply via email to