If you read my original post, I had no intention of atributing the
user's method to the class, but to the instance.

Anyway I figure it out myself, and its quite a Pythonic solution:
>>> class Foo:
            name='John'

>>> a=Foo()

>>> def p(parent):
            self=parent
            print 'Hi, %s!'%self.name


>>> a.met=p

>>> a.met(a)
Hi, John!

This works the same way an object's built-in method would work, since
all methods receive a reference to the parent object through the
required argument "self".

class Foo:
   def met(self):
       print self

Thanks for all the replies, they helped to catalize my own thoughts!

Flávio

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

Reply via email to