News for hackers. Stuff that matters.
Re:Common Python Mistakes by kghose on Thursday May 08, 2014 @11:24AM (#7715766)

  import datetime, time
  def foo2():
    def foo(a=datetime.datetime.now()):
      time.sleep(1)
      return a
    return foo()

  for n in range(10): print foo2()

  2014-05-08 11:23:01.642871
  2014-05-08 11:23:02.644276
  2014-05-08 11:23:03.644579
  2014-05-08 11:23:04.645146
  2014-05-08 11:23:05.646328
  2014-05-08 11:23:06.647572
  2014-05-08 11:23:07.647904
  2014-05-08 11:23:08.648213
  2014-05-08 11:23:09.648973
  2014-05-08 11:23:10.649742
So, not quite module load time, but evaluation time.
Re:Common Python Mistakes by marcosdumay on Thursday May 08, 2014 @11:40AM (#7715856)
Kilink's comment apply again.

If you define several functions at different times, the default argument will be evaluated each time you define a new function. You'll have the same behaviour if you keep reassigning lambdas at the same function name, or if you keep edditing the globals.

You are misunderstanding how dynamic Python is. And, yes, the part about "module load time" was a simplification.

Re:Common Python Mistakes by herge on Thursday May 08, 2014 @11:31AM (#7715804)
You are technically correct, the best type of correct. The top level function is evaluated at module load time.