On 4/19/2016 11:41 PM, Chris Angelico wrote:
On Wed, Apr 20, 2016 at 1:23 PM, Terry Reedy <tjre...@udel.edu> wrote:
It kinda looks like Hypertalk syntax, which some of you may remember I'm
exceedingly fond of. There's no reason why a GUI editor couldn't display
Python code using such "building block" structure. E.g. indented blocks
could use colour and shape cues to reinforce the structure of the code,
just as Scratch does.


That is an interesting idea.  Perhaps I have been stuck in either/or
thinking -- either graphical or textual. With tk Text (IDLE), it would be
possible to tag each (4-space) indent with a color for the compound
statememt keywork causing the indent.


Interesting indeed! Tell me if I've understood you correctly. You'd
display this code:

def func(x):
    for n in range(1, x):
        while n < x:
            if n % 2:
                n = (n + 1) * 3 / 2
            else:
                n = n * 2 + 3

with stripes of colour, with the entire first column of spaces all
tied to the "def", and then the next block of four tied to the "for",
etc?

Exactly.

> That'd be pretty cool, and a neat way to help people transfer
their skills from Scratch to Python.

(Would "else" be in the same colour as "if"? What about "elif"?)

To be determined ;-). Perhaps different shades. Scratch uses one color for all control: while, if, else, but that would not work for python with so much more nesting. Scratch needs different colors for much broader categories as many are not for syntax but for groups of functions that in Python would be in imported modules. I would like nested for loops to have slightly different shades, but I would not necessarily start with that, unless each compound statement got a new tag and color.

What makes the idea not completely ridiculous is that IDLE already keeps track of indents for its smart indenting and code context features.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to