keeping Python code properly indented

Jason Mobarak jmob at nospam__unm.edu
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/base.py 9 '\tfrom shtoom import prefs \n'
./test/test_stun.py 18 "\tn1 = NetAddress('10/8')\n"
./audio/__init__.py 21 '\taudio = attempt()\n'
./multicast/unixspec.py 24 '\tgroup = gethostbyname(addr)\n'
./multicast/SAP.py 8 '\tself.dismantlePacket(pack)\n'
./multicast/SDP.py 35 "\tlines = text.split('\\n')\n"
./multicast/netnum.py 10 '\tl = l+[0]*(4-len(l))\n'
./rtp.py 128 '\treturn d\n'


beliavsky at aol.com 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