need an alternative to getattr()

2006-08-07 Thread [EMAIL PROTECTED]
Hi, AIM: I have a config file that contains configuration under headings like this: heading1: configuration 1 configuration 2 heading2: configuration 1 configuration 2 ... ... i parse this file to get heading1, heading2, etc and then i want to call heading1.process(), heading2.process(), etc.

Re: need an alternative to getattr()

2006-08-07 Thread Uffe Wassmann
I think you would benefit from looking at the ConfigParser module. I haven't tried it yet, but it looks like a nice interface for writing and reading configuration files. -Uffe. On 7 Aug 2006 07:30:41 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, AIM: I have a config file that

Re: need an alternative to getattr()

2006-08-07 Thread Ant
getattr(heading, process)(file_ptr) ... Is there an alternatice to getattr() that will solve my problem, or is there another way to do it. How about: eval(%s.process(%s) % (heading, file_ptr)) -- http://mail.python.org/mailman/listinfo/python-list

Re: need an alternative to getattr()

2006-08-07 Thread Jon Ribbens
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: import heading1 import heading2 While True: heading = get_next_heading(file_ptr) # This func will return heading1, then heading2(on next call) if heading = : break getattr(heading, process)(file_ptr) # The problem,