Building a function call?

Roland Heiber newstonne at web.de
Wed Jul 13 14:42:52 CEST 2005


Francois De Serres wrote:
> Hiho,
> 
> Having a string: "dothat"
> and a tuple: (x, y)
> 1. What's the best way to build a function call like: dothat(x,y)?

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)

----
Called with: 1 2

HtH, Roland



More information about the Python-list mailing list