Paramaterized local variable name

Tim Cera timcera at earthlink.net
Sun Dec 30 06:15:56 CET 2001


Hello,

I have the following code:

def paging(data, key, query_dict):
  for i in range(0, len(data[key]), use_pagesize):
    start = data[key][i].name
  ...etc.

which works fine for data[key][i].name, but sometimes I want this
function to process data[key][i].rev.

So, if local_name is equal to 'name' or 'rev' or 'whatever', what I
want is something like:

def paging(data, key, query_dict, local_name):
  for i in range(0, len(data[key]), use_pagesize):
    start = data[key][i].
#       What goes here   ^^^^  ?

Thanks
Tim Cera



More information about the Python-list mailing list