I've got a pretty good understanding of python's try-except clause, but I'm encountering problems when trying to put it inside of a function.
>>> def tryAppend(child, parent):
... try:
... parent.append(child)
... except NameError:
... print "WRONG NAME"
>>> var1 = []
>>> var2 = 'test2'
>>> tryAppend(var2, var1) #works, no error
>>> tryAppend(foo, var1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'foo' is not defined
it is almost like python doesn't see the try: statement. Any help is appreciated.