how to get a reference to the "__main__" module

WH whzhao at gmail.com
Wed Jun 9 01:29:04 EDT 2010


Hi,

I want to use one of two functions in a script:

def func_one(): pass
def func_two(): pass

func = getattr(x, 'func_'+number)
func()

'x' in getattr() should be a reference to the "__main__" module, right?
 How to get it?  The 'if' clause should work here.  I am just curious if
we can use the above method.

Thanks,
-WH



More information about the Python-list mailing list