Roland Heiber wrote:
> Not the best (not at all) but one way:
> 
> def dothat(x,y):
>   print "Called with:", x, y
> 
> c = (1,2)
> 
> locals().get("dothat")(*c)

As you say, not the best, but in fact not really advisable under any 
circumstances.  locals() returns "module level" stuff only when executed 
_at_ module level (i.e. not inside a function).  Otherwise it will 
return only the local variables of the frame its in.

Better is this, since it works for the OP's requirements in either 
situation.

   globals()['dothat'](*c)

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to