How an editor can help with block nesting (was Re: How coding in Python is bad for you)
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
@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.
[box with a dash inside of it ]if __name__ == "__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.
More information about the Python-list