On Thu, Dec 27, 2012 at 6:26 PM, Abhas Bhattacharya
<abhasbhattachar...@gmail.com> wrote:
> During run-time, I can always use: function_name.__name__ (although that's 
> kind of lame because it returns "function_name"). But if the function itself 
> contains print(__name__) and I call the function, it returns __main__ (yes, 
> __main__ itself, not the string "__main__") (which is the calling function).

That's because __name__ looks for that attribute on the module (aka
"global variable"), not the function. When you run your Python script
as an application, the module is called __main__.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to