Adding methods to an object

rcramsdell at gldd.com rcramsdell at gldd.com
Thu Oct 13 15:47:24 CEST 2005


gabriele,

This works (A, Test, and o as defined by you):

>>> a=A()
>>> o.do(a, 10)
10

Your problem is that do() really has two parameters, an A instance and
whatever you want to print.

Why not do this:

>>> def newdo(m):
... 	print m
...
>>> newdo(10)
10
>>> o=Test()
>>> o.newdo = newdo
>>> o.newdo(10)
10

Robert




More information about the Python-list mailing list