Re: how to get a reference to the "__main__" module

2010-06-13 Thread Aahz
In article , WH wrote: > >'x' in getattr() should be a reference to the "__main__" module, right? >How to get it? Just for the record, the best way to get a reference to __main__ is to import it: import __main__ -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/

Re: how to get a reference to the "__main__" module

2010-06-08 Thread Steven D'Aprano
On Tue, 08 Jun 2010 22:29:04 -0700, WH wrote: > 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?

Re: how to get a reference to the "__main__" module

2010-06-08 Thread Chris Rebert
On Tue, Jun 8, 2010 at 10:29 PM, WH wrote: > 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? from sy

how to get a reference to the "__main__" module

2010-06-08 Thread WH
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