I'm beginning to believe I am being incredibly dense today ... On Sat, Feb 4, 2017 at 6:16 PM, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > boB Stepp <robertvst...@gmail.com> writes: > >> But would it not be more consistent to assume the user knows what he >> is doing based on the new (lack of) indentation being used, accept >> that a new section of code outside of the for loop is being typed in, >> and wait for the blank line before executing everything typed in? > > That's not the purpose of the REPL. It is to Read (one statement), > Evaluate the statement, Print the result, and Loop. > > You're wanting a different behaviour: wait until all the input has been > read, then evaluate it all.
Ben, I read your answer, did some Googling on REPL, seemed satisfied, and consigned this thread of emails to the trash bin, believing it was all settled in my mind. But then I got to wondering again ... As already mentioned the interactive interpreter handles multiline statements. In the case of defining a function, the interpreter allows quite complex, nested code to be entered, only ending the input of code process when that blank line occurs in proper context. By this I mean that quotes have been properly closed, all parens matched, etc. 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. The interpreter cannot know that the user has finished inputting code until it encounters that finalizing blank line. After all I can have in my function many for loops followed by unindented print functions in seeming as much complexity as I can bear to type in accurately. This is giving exactly the consistent behavior that I would expect. But if instead of starting with a for loop inside a function with following unindented other statements I instead start with *exactly the same sequence of statements* but without "def ...:", then I get a syntax error. I am not trying to be deliberately argumentative, but I do not see why the two cases are treated differently when the entered code is exactly the same between the two with the sole exception of one has an enclosing function definition line the other code does not. I am continuing to scratch my evermore balding head on this one! But it is not a big deal, and I do not want to blow things out of proportion. More practically, I wonder if it is all as simple as not having to hit the enter key twice for true one-liner statements. Such lines can truly be handled one line at a time per REPL. If I had things "my way", then that would make the more common situation of true one-line-at-a-time read-evaluate-print-loop more cumbersome. -- boB _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor