How an editor can help with block nesting (was Re: How coding in Python is bad for you)

Ben Iannitelli cannedham284 at hotmail.com
Wed Jan 25 10:13:15 EST 2017


On Wed, Jan 25, 2017 at 6:31 AM, Ben Bacarisse <ben.usenet at bsb.me.uk><mailto:ben.usenet at bsb.me.uk> wrote:

In Python the editor could, for example, highlight the block you are
typing in, so as soon as you leave the body of the 'if' it would stop
being marked and the containing code would be highlighted.  Just moving
the cursor up and down would show you what block everything is in.  I
don't know if any editors help like this -- that's part of my reason to
ask.
@Ben B.: Have you had a look at Notepad++? When it detects that you're editing a Python file, a ruler on the left-hand margin of the editing window employs a system of boxes and lines to show which blocks of code belong to which conditional clause, with those pertaining to the current block in red.

Below are attempts to sketch it out without the benefit of screenshots or color.
First attempt:
[box with a dash inside of it ]if __name__ == "__main__":
[U+2514]    main()

Second attempt (imagine that your cursor is somewhere in the same line as the "print" statement) :
[box with a dash inside of it, in gray ]def main():
[box with a dash inside of it, in gray ]    with open("some_spreadsheet.csv",newline='') as sheet:
[U+2502, in gray]        data = csv.DictReader(sheet)
[box with a dash inside of it, in RED ]        for n,row in enumerate(data):
[U+2514, in RED]            print(n,row)

I didn't do it justice, but that's honestly the best I can do. If you can find the time to install it and then play with it, you can actually see for yourself whether that feature is loyal to the idea you described.


HTH


-Ben I.



More information about the Python-list mailing list