On 10/8/2016 2:56 AM, Steve D'Aprano wrote:
Just copy and paste it into your Python IDLE and let me know what you get
I don't normally use IDLE, and you shouldn't assume that everyone does.
*That* is the extra information we need to solve the problem:
The IDLE interactive interpreter in Python 3 does not seem to allow you to
paste multiple lines at once.
Actually, it does. I pasted the following multiline statement.
>>> while not done:
for event in pygame.event.get(): # User did something
if event.type == pygame.QUIT: # If user clicked close
done = True # Flag that we are done so we exit this loop
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
while not done:
NameError: name 'done' is not defined
ie, the single statement was compiled.
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
SyntaxError: multiple statements found while compiling a single statement
Here you pasted multiple *statements* (on separate lines). This is a
known difference between console and IDLE Shell. It is partly related
to being line versus statement oriented, partly due to window paste
being handled by system console versus tk => tkinter => IDLE run by
python. Note that in a console, each line is preceded by the primary
prompt ('>>> '). Ditto if one types the lines into IDLE.
There has been some discussion of changing IDLE, but it would not be
trivial. The console splits pasted text into lines and feeds a line at
a time to Python. IDLE would have to intercept the pasted text before
tk displays it, parse (split) the paste into statements (rather than
lines), and display and run one statement at a time. I would rather
spend the effort on making it possible to run code in a new editor
window without explicitly saving it.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list