Python's Technical Humor: the __main__ Stanza
here's a snippet of Python doc:
This module represents the (otherwise anonymous) scope in which the interpreter's main program executes — commands read either from standard input, from a script file, or from an interactive prompt. It is this environment in which the idiomatic “conditional script” stanza causes a script to run:if __name__ == "__main__": main()
from 27.5. __main__ — Top-level script environment — Python v2.7.6 documentation #module-__main__
notice the word “stanza”? Here's a technical writing in a technical manual, and in comes a technical term of poetry. This must be a technical humor.
from the few writings of Guido i've seen, am gussing Guido wrote this piece. His writing's always a bit odd.
__main__ is a prototypical hack. It came into being because Python's trying to have a consistent namespace scheme: module has namespace, therefore global stuff must belong to some “module” too, thus this pseudo-module
__main__ was born.
from which, we begot this common nonplus:
if __name__ == "__main__": print "I ran as script!"
- Optional Function Parameters in Computer Language Docs (the idiocy thereof)
- Python Documentation Problems
- Why Python's Documentation Sucks
- Python Doc Problem Example: os.system
- Python Doc Problem Example: os.path.split()
- Python Doc Problem Example: sort()
- Python Doc Problem Example: gzip
- On Python Documentation
- The Idiocy of Python's Function Parameter Specification
- Python Syntax Problem: Complexity of Comment Syntax and Backslash
- Why Python's Lambda is Broken and Can't be Fixed
- Syntax Design: Python's Indentation vs Nesting
- Python Bitwise Invert Oddity
- Python Scope Complexity, Shallow Copy, Deep Copy, Circular List, and the Garbage Underneath Computer Languages
- Python's Context Dependent Syntax Soup: 「… in …」 And 「… not in …」