Re: Building a function call?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Building a function call?

From: Roland Heiber <newstonne@web.de>
Date: Wed Jul 13 2005 - 14:42:52 CEST

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
Received on Thu Sep 29 16:55:32 2005