[Edu-sig] How to pass parameters to eval?

Kirby Urner urnerk@qwest.net
Wed, 26 Sep 2001 16:57:53 -0700


>
>********func.py***************
>def fun ():
>    print v1+v2
>
>**************pro.py***********

You can save:

  def fun (v1, v2):
      print v1 + v2

as func.py, then go:

  >>> from func import *
  >>> funname = fun
  >>> v1 = "Hello"
  >>> v2 = "World"
  >>> eval("funname(v1,v2)")
  HelloWorld

Of course the easier thing would be to just
go:

  >>> from func import *
  >>> fun("Hello","World")
  HelloWorld

But I assume you have your reasons...

Kirby