[EDIT: this question is not a duplicate of this; I am asking a question of language design, i.e. why it is this way in the first place. I am not confused about how it behaves, I am confused about why this behavior was decided upon in the first place.] In Python (and some other languages, e.g. Lua), the boolean operators
Tag: language-design
Loose late binding v. strict late binding
While reading Python’s Execution model documentation, I realized that Python’s free variables do not seem to have a strict late binding property where a name binding occurring in any code block can be used for name resolution. Indeed, executing: raises: They have rather a loose late binding property where only a name binding occurring in an outer code block of
What’s the difference between __builtin__ and __builtins__?
I was coding today and noticed something. If I open a new interpreter session (IDLE) and check what’s defined with the dir function I get this: Please note the last line. So, my question is: Is any an alias of the other one? Are the Python guys planning to get rid of one of those? What should I use for
“Least Astonishment” and the Mutable Default Argument
Anyone tinkering with Python long enough has been bitten (or torn to pieces) by the following issue: Python novices would expect this function called with no parameter to always return a list with only one element: [5]. The result is instead very different, and very astonishing (for a novice): A manager of mine once had his first encounter with this