no SyntaxError?
Robert W. Bill
rbill at digisprings.com
Tue Jun 13 16:13:48 EDT 2000
Just curious- I didn't find any references to this in a quick search of
the faq and elsewhere...
This snippet generates "SyntaxError: invalid syntax"
def test():
else: print "whoops"
test()
However, the following snippet generates "0 1 whoops" when it seems like
it should also generate "SyntaxError: invalid syntax" because there is no
if before the else.
def test1():
for i in range(2):
print i,
else:
print "whoops"
test1()
Why is it that I do not get a "SyntaxError" in the second example?
rb
More information about the Python-list
mailing list