News for hackers. Stuff that matters.
Re:Anti-Patterns in Python Programming by deathanatos on Wednesday July 09, 2014 @12:25PM (#8010488)
> The default value gets created when the function is interpreted ("compiled").

No. The default value gets "created" (the expression is evaluated and stored) when the def statement is executed. Take the following example:

  In [1]: def foo():
     ...:     def append_five(l=[]):
     ...:         l.append(5)
     ...:         return l
     ...:     return append_five
     ...:

  In [2]: a = foo()

  In [3]: b = foo()

  In [4]: a()
  Out[4]: [5]

  In [5]: b()
  Out[5]: [5]

  In [6]: _4 is _5
  Out[6]: False
We only wrote one function definition, but multiple lists are created. (They are created when the "def append_five" definition executes, during the execution of foo.)
Re:Anti-Patterns in Python Programming by tmerr on Wednesday July 09, 2014 @08:39PM (#8012993)
I thought that was what he meant. Is there any sharp distinction between "interpreting" and "evaluating" in python that I am unaware of? I've always used the words more or less interchangeably. But now that I think about it that might be a little naive since I have no idea how it works under the hood
Re:Anti-Patterns in Python Programming by msellout on Thursday July 10, 2014 @02:37AM (#8013912)
You could say that interpreting is first parsing and second executing/evaluating. The parser tokenizes and does a small amount of optimization such as ignoring unassigned values.
Re:Anti-Patterns in Python Programming by gcr on Wednesday July 09, 2014 @11:58PM (#8013527)
The parent wrote "compiled", which is certainly more incorrect than either "interpreted" or "evaluated."