how to get a reference to the "__main__" module

Aahz aahz at pythoncraft.com
Sun Jun 13 12:40:50 EDT 2010


In article <hun8s4$h4l$1 at news.albasani.net>, WH  <whzhao at gmail.com> 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 (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra



More information about the Python-list mailing list