dynamically generating function assignent
bjorn at roguewave.com
Mon Nov 1 19:59:14 CET 1999
You can do:
fn = eval('func_' + 'a') # look it up in the environment
> -----Original Message-----
> From: anantk at my-deja.com [mailto:anantk at my-deja.com]
> Sent: Monday, November 01, 1999 11:19 AM
> To: python-list at python.org
> Subject: dynamically generating function assignent
> Here is my problem. I have defined say 12 pairs of functions
> A file contains a series of strings which are the names of these
> functions eg:
> Now for each of these strings I need to call the two functions
> func_<x>(), and parse_func_<x>(), where <x> is the name of
> the function
> that string refers to.
> I know you can do something like
> call = func_a, and call effectively gets assigned to func_a. My
> question is how can I generate the RHS of this assignment dynamically?
> So that all I have to do is
> <variable> = <next line in file>
> call1 = func_<variable>
> call2 = parse_func_<variable>
> Any help would be appriciated.
> -- Anant
> anantk at yahoo.com
> Sent via Deja.com http://www.deja.com/
> Before you buy.
More information about the Python-list