> Why not just: > > import whatevermynameis > > whatevermynameis.foo = bar > > This would be even *more* maximally obvious, as you wouldn't need to > know what '__me__' means. :) And how often do you write a module > without knowing what its name is, or change the name after you've > written it? Plus, thanks to the time machine, it already works. :) Doesn't work when your module may either be called __main__ or rumpelstiltkin. It would then become if __name__ == "__main__": import __main__ as me else: import rumpelstiltkin as me which loses the "aha!" effect of a cool solution. It also IMO requires too much explanation to the unsuspecting reader who doesn't understand right away *why* rumpelstiltkin imports itself. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4