February 2010 (1)
September 2009 (1)
May 2009 (1)
April 2009 (1)
March 2009 (4)
January 2009 (3)
November 2008 (2)
October 2008 (2)
September 2008 (1)
August 2008 (5)
July 2008 (3)
June 2008 (1)
May 2008 (5)
April 2008 (8)
March 2008 (3)
February 2008 (1)
January 2008 (2)
December 2007 (2)
November 2007 (4)
October 2007 (17)
September 2007 (9)
2009-04-30 16:41:03
So I haven’t been doing a lot of Python recently, and I got tripped up by something that in retrospect should have been obvious.
You can write code that references an undefined thingy, and Python won’t complain until you actually run the code and try to access the thingy.
Eg:
>>> def f():
... z()
...
>>> f()
Traceback (most recent call last):
File "", line 1, in
File "", line 2, in f
NameError: global name 'z' is not defined
Which kind of sucks when you forgot to write a test for that code, and you get a runtime exception.
Rendered at 2012-02-10 00:19:35