Building a function call?
Peter Hansen
peter at engcorp.com
Wed Jul 13 10:16:57 EDT 2005
Roland Heiber wrote:
> Even with globals(), I think its a bit odd ..., but safer than using
> eval() ...
Some would agree and claim that using an import is better:
c = (1, 2)
thisModule = __import__(__name__)
func = getattr(thisModule, 'dothat')
func(*c)
I don't generally find that more readable than the one with globals(),
and I don't offhand recall any serious criticism of globals() on grounds
of either readability or style, so I'm unsure why anyone would prefer
the alternative.
-Peter
More information about the Python-list
mailing list