call to function by text variable

Wojciech Muła wojciech_mula at poczta.null.onet.pl.invalid
Sun Mar 25 18:48:19 EDT 2007


ianaré wrote:
> like this:
> 
> 
> list = ["Replace", "ChangeCase", "Move"]
> textVariable = list[n]
> self.operations.insert(pos, operations.[textVariable].Panel(self,
> main))
> 
> Is something sort of like that possible?

Yes:

self.operations.insert(
	pos,
	getattr(operations, textVariable).Panel(self.main)
)



More information about the Python-list mailing list