dynamic invoke

Jarek Zgoda jzgoda at o2.usun.pl
Mon Oct 22 04:14:13 EDT 2007


Sushant napisał(a):

> getattr seems to be converting string into function pointer and I am just 
> saying that string cannot be used as a function pointer in Python as may be 
> in PHP.

It seems, but it does not. Getattr performs lookup on object's
attributes dict, it does not "convert" anything. The abstraction of
"function pointer" is also wrong here, it's a reference to an object
(any object, not just function). The result might seems similar, but
works quite differently.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)



More information about the Python-list mailing list