[Tutor] Tutor Digest, Vol 54, Issue 63

Lie Ryan lie.1296 at gmail.com
Sun Aug 17 15:24:45 CEST 2008


> Message: 3
> Date: Sun, 17 Aug 2008 01:28:23 -0400
> From: xbmuncher <xboxmuncher at gmail.com>
> Subject: Re: [Tutor] Is there python editor or plugin for a python
>         editor  for curly brackets around code blocks?
> To: "Timothy Grant" <timothy.grant at gmail.com>
> Cc: tutor at python.org
> Message-ID:
>         <df531c470808162228y25eeb915j286ac0933d36e08d at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> I talked about earlier how the main problem for me wanting to use
> curly
> braces is because of the visual ease of seeing the end of the code
> blocks..
> well you can change the indention guidelines on most code editors to a
> bright color and this might be the next best thing. Also a good
> feature to
> implement is just like there are highlighted curly braces when your
> mouse or
> key presses are inside certain code blocks, they should highlight or
> change
> the indentation guides to the same effect....

Highlighted braces are only useful for detecting misleading indentation,
in python, since indentation is part of the syntax (instead of just a
visual marker) highlighting brace/indentation lost 50% of its
usefulness.

In python, to see where a block ends, you just need to skim for the
first line that have less indentation than the current block. 

Well, admittably, in a multilevel block that ends at the same time, it
is sometimes hard to identify which level is ended, especially if the
indentation is small:

def blah():
 def innerfunc(foo):
  for i in range(100):
   if i == foo:
    while i:
  i -= 1
  for i in range(10):
   print i
 innerfunc(10)

but that's why PEP 8 (Style Guidelines) recommends using 4 spaces which
is quite a lot. Anyway, if you have a code that is more than 4 levels
deep, it is a good indication that it may require refactoring.



More information about the Tutor mailing list