This is a valid Python program:

def f(): pass
print(f)

But at the REPL:

>>> def f(): pass
... print(f)
  File "<stdin>", line 2
    print(f)
    ^
SyntaxError: invalid syntax

It doesn't seem to matter what the second line is.  In the REPL you have to leave a blank line after the "def" line.  Why?
Tested am using Python 3.8.3 and 2.7.18.

Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to