I did not know about getattr and it is the right thing. 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.
I copied the PHP code so I did not replace arrow with dot. Good point :) -Sushant. On Friday 19 October 2007 11:05 am, Diez B. Roggisch wrote: > Sushant wrote: > > Python will not allow string to be used a function pointer. It is type > > unsafe. Best way is to convert string into function pointers manually. > > > > if dynamicMethod == 'bar': > > method = oFoo->bar > > else: > > method = oFoo->default > > method() > > Sorry to say so, but that answer is bogus. It's not even Python! > > Jarek has already shown how to solve this problem. And type-safety-issues > have nothing to do with it at all. > > Diez -- http://mail.python.org/mailman/listinfo/python-list