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, as you would > have noticed, is that the first > # argument to getattr is a string!! > > Is there an alternatice to getattr() that will solve my problem, or is > there another way to do it.
globals()[heading].process(file_ptr) or sys.modules[heading].process(file_ptr) but note that, unless you are checking 'heading' against a 'known good configuration keywords' list beforehand, you are trusting the author of the configuration file. -- http://mail.python.org/mailman/listinfo/python-list