keeping Python code properly indented

Jason Mobarak jmob at
Fri Jan 16 11:11:41 CET 2004

The tabnanny module/program is a very good way to make sure python files 
are properly indented.

@ares shtoom --> python -c "import tabnanny; tabnanny.check('.')"
./ui/ 9 '\tfrom shtoom import prefs \n'
./test/ 18 "\tn1 = NetAddress('10/8')\n"
./audio/ 21 '\taudio = attempt()\n'
./multicast/ 24 '\tgroup = gethostbyname(addr)\n'
./multicast/ 8 '\tself.dismantlePacket(pack)\n'
./multicast/ 35 "\tlines = text.split('\\n')\n"
./multicast/ 10 '\tl = l+[0]*(4-len(l))\n'
./ 128 '\treturn d\n'

beliavsky at wrote:
> How do you keep Python code properly indented as you modify it? I use
> an Emacs-type editor that has a Python mode, so the initial indenting
> is easy. If I later want to put a 'for' loop (or an 'if' statement)
> around a bunch of code, I find myself going through the body of the
> loop, manually re-indenting to keep the nested loops correct. There
> should be a better way.
> I think that having a 'for' loop end with a matching 'next' statement,
> as done in (for example) Basic, is a safer and clearer way of writing
> loops, although some Python programmers consider this a 'feature'
> rather than a 'bug'.

  )~~~~~ Jason A. Mobarak ~~~~~~~)
(~~ aether_at_gentoo_dot_org ~~(
  )~~~~ jmob_at_unm_dot_edu ~~~~~)

More information about the Python-list mailing list