Interestingly, if you're just typing at the python interactive interpreter, you have to follow a function with a blank line. This does not work:
def foo(x):
return x+1
print "last"
although it is perfectly legal python syntax in a file. There are other syntactic differences when typing to the interpreter too, so beware.