Python syntax in Lisp and Scheme

Bengt Richter bokr at oz.net
Mon Oct 6 07:17:01 EDT 2003


On Mon, 6 Oct 2003 11:39:55 +0200, Gerrit Holl <gerrit at nl.linux.org> wrote:

>Ingvar Mattsson wrote:
>> It's actually even worse than you think. Imagine you want "blank
>> lines" in your code, so act as paragraph separators. Do these require
>> indentation, even though there is no code on them? If so, how does
>> that interact with a listener? From what I can tell, the option chosen
>> in the Python (the language) community, the listener and the file
>> reader have different view on blank lines. This makes it harder than
>> necessary to edit stuff in one window and "just paste" code from
>> another. Bit of a shame, really.
>
I think I agree somewhat. The problem is detecting end-of-chunk from the user input.
I think it would be possible to write a different listener that would accept
chunks terminated with an EOF from the user using some key binding, like a function key
or Ctl-z or Ctl-d. Then you could type away until you wanted it interpreted.
A zero length chunk followed by EOF would terminate the overall listener.

The source is open if you want to try it ;-) Let us know how it feels to use.
Alternatively, maybe interactively postponing blank-line dedent processing until the
next line would be better. Two blank lines at the end of an indented series of chuncks
separated by a single blank line would be fairly natural. If there was no indent legal
on the next line, you'd process immediately, not go to ... prompt. But this is tricky
to get right.

>Blank lines are ignored by Python.
>
You are right re the language, but the interactive command line interface (listener)
doesn't ignore them. (Its syntactical requirements are a somewhat separate issue from
Python the language, but they are part of the overall Python user experience):

 >>> def foo(): print 'foo'
 ...
 >>> foo()
 foo
 >>> if 1:
 ...     def foo(): print 'foo'
 ...     foo()
 ...
 foo

Regards,
Bengt Richter




More information about the Python-list mailing list