Speaking Python
eichin at metacarta.com
eichin at metacarta.com
Tue Oct 14 13:45:11 EDT 2003
In <slrnb4frf3.cp.mlh at furu.idi.ntnu.no>, I was pointed at "pindent.py"
as a useful convention for dealing with "silent whitespace" (when I
asked about the same problem - helping a blind coworker [who is a
hardcore C, C++, and perl developer] deal with python code. We
haven't actually had a chance to work together using it, so I don't
know if it actually helps, but since I haven't noticed it mentioned on
this thread...
> Yes. See the script pindent.py in Tools/scripts in your Python
> distribution. It basically closes every intented block with an "end"
> comment. The script can be used both to add this sort of marking, and
> to remove it -- and restore indentation if it has been destroyed.
>
> This, according to the pindent convention,
>
> def foobar(a, b):
> if a == b:
> a = a+1
> elif a < b:
> b = b-1
> if b > a: a = a-1
> # end if
> else:
> print 'oops!'
> # end if
> # end def foobar
>
> is equivalent to
>
> def foobar(a, b):
> if a == b:
> a = a+1
> elif a < b:
> b = b-1
> if b > a: a = a-1
> # end if
> else:
> print 'oops!'
> # end if
> # end def foobar
>
> or even
>
> def foobar(a, b):
> if a == b:
> a = a+1
> elif a < b:
> b = b-1
> if b > a: a = a-1
> else:
> print 'oops!'
>
> Since this script has been in the Python distro for years, it seems
> like the most "standard" convention to adopt, IMO.
>
> --
> Magnus Lie Hetland "Nothing shocks me. I'm a scientist."
> http://hetland.org -- Indiana Jones
More information about the Python-list
mailing list