comments and the continuation prompt
Terry Reedy
tjreedy at udel.edu
Mon Jun 26 02:03:21 EDT 2017
On 6/25/2017 11:32 PM, Ben Finney wrote:
> Steve D'Aprano <steve+python at pearwood.info> writes:
>
>> On Mon, 26 Jun 2017 08:44 am, Stefan Ram wrote:
>>
>>> According to The Python Language Reference Release 3.6.0, 2.1.3
>>> Comments, »A comment signifies the end of the logical line unless
>>> the implicit line joining rules are invoked.«.
>>>
>>> So, why do I get a continuation prompt when I enter a comment?
In IDLE, you don't.
>>> #
>>> #sjflksj
>>>
Maybe this was once true for the interactive interpreter and changed.
Or maybe this is buglet in IDLE in terms of imitating the console
interpreter. I have no idea.
>> Why not? As far as the interactive interpreter is concerned, you
>> haven't yet entered a statement.
>
> And yet, according to the Language Reference, the logical line has ended
> and another begun.
>
> So I think the question is worth exploring: Why does the interactive
> prompt imply the logical line is continuing, when the Language Reference
> would say otherwise?
>
> Maybe the answer is “the continuation prompt does not prompt for the
> continuation of a logical line, but the continuation of <something
> else>”.
>
> What exactly goes in the “<something else>” placeholder; that is,
> exactly what should the user understand by that transition from one
> prompt to a different one?
Look into the behavior of compile('code', 'fake', 'single').
--
Terry Jan Reedy
More information about the Python-list
mailing list