Passing to a function -- object and method names (or references)

Midas M at a.k
Fri Jan 2 21:17:41 CET 2004

Peter Otten wrote:

>You can access attributes with the getattr() builtin.
>carGas = getattr(car, "gas")
>You can refer to a method either directly 
>fun = 
>or via getattr():
>fun = getattr(car, "drive")
>I've modified your example to demonstrate this. 

Thank you very much, Peter! It works nicely!


More information about the Python-list mailing list