On Tue, Dec 1, 2009 at 3:17 PM, Jean-Michel Pichavant < jeanmic...@sequans.com> wrote:
> Victor Subervi wrote: > >> Hi; >> I have the following code that execute without a problem: >> >> import sys,os >> sys.path.append(os.getcwd()) >> import options >> storesTables = [] >> junkStores = string.join(addStore(), ', ') >> for table in optionsTables(): >> if table not in ('particulars', junkStores): >> storesTables.append(table) >> for table in storesTables: >> try: >> fn = getattr(options, table) >> print fn() >> except: >> pass >> >> I need to change the obvious line to this or something similar (that >> actually works): >> >> fn = getattr(options, '%s("names")' % table) >> >> That is, I need to pass the variable "names" to each table as it is >> called. How do I do this? >> TIA, >> Victor >> > I'm not sure I understood what your are trying to do. > > > try: > fn = getattr(options, table) > fn(names) > except: > pass > Thank you. V
-- http://mail.python.org/mailman/listinfo/python-list