Nov. 26, 2013
3:29 a.m.
On 11/25/2013 09:04 PM, Alexander Belopolsky wrote:
That's news to me. It was not so as of 3.3.3:
Python 3.3.3 (default, Nov 25 2013, 15:41:46)
def f(): ... print(__name__) ... f() __main__
If anything, it is a magic function relying on _getframe() run-time introspection that would have a problem working inside functions.
Woops.. yep. Hmmm, Wonder what I came across recently to make me think that. Oh well. I still think there would be some advantages from comparing the actual modules rather than the __name__ attribute. Jan pointed out some use cases. Cheers, Ron