On 05/02/17 01:29, boB Stepp wrote: > But it seems to me on further thought that both REPL and what seems > most consistent to me, "...wait until all the input has been read, > then evaluate it all..." amounts to the same thing in the case of > entering function definitions into the interpreter.
Nope, the function definition is a single executable statement. def is a command just like print. The command is to compile the block of code and store it as a function object that can later be called. So the interpreter is being completely consistent in looking for the full definition in that case. You are right that the interactive interpreter *could* have read all input before executing it, but by design it doesn't. It is an arbitrary choice to make the interpreter act on a single input statement at a time (and personally I think a good one). The problem with executing multiple statements at a time is that your mistakes are often not where you think they are. And by showing you the output of every statement as you go you notice the error as it happens and don't mistakenly make assumptions about which of the previous N statements contains the bug. So personally I prefer the Python style interpreter. Perl by contrast is more like your preference and interprets to an EOF and I find that too easy to make mistakes. Best of all I guess is Smalltalk which executes any code you highlight with a mouse... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor