dynamically generating function assignent

anantk at my-deja.com anantk at my-deja.com
Mon Nov 1 19:19:02 CET 1999


Hi,

  Here is my problem. I have defined say 12 pairs of functions

func_a()
parse_func_a()

func_b()
parse_func_b()
.
.
func_l()
parse_func_l()

  A file contains a series of strings which are the names of these
functions eg:

a
c
f
b

  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>
  call1()
  call2()

  Any help would be appriciated.

  Thanks

-- Anant
   anantk at yahoo.com


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list