[Tutor] Indentation Issue and Blind People

Kent Johnson kent37 at tds.net
Fri Nov 30 20:37:36 CET 2007


james.homme at highmark.com wrote:
> Hi,
> I am just getting started with Python, as in learning the syntax for basic
> statements and how to write functions and all. Here is my question.
> Usually, if you are a person who is blind, you run the risk of having
> trouble keeping your code indented properly. There are ways to do it, but
> they are often time-consuming. Can I get a program that I can use that will
> take my Python code as input and make sure it is indented properly?

Not really. The 'proper' indent depends on what you want to do. For 
example both of these snippets are correct:

if a==1:
   x=2
   y=3

if a==1:
   x=2
y=3

The best you can do is check that the code is syntactically correct, 
which the compiler does.

> Or,
> does Python let you write code, compile it, and indent it later?

No, if it is not syntactically correct it will not compile.

You might be interested in PyFlakes. It will syntax check your code 
without executing it.
http://divmod.org/trac/wiki/DivmodPyflakes

> For anyone
> who may be interested, I have created a scheme for my screen reader that
> plays piano notes at indentations of two space increments. I made the code
> indent that way because four spaces is a lot to have on a braille display.
> If four spaces is more acceptable, I could globally replace two spaces with
> four.

Four spaces is more common but two spaces should be fine.

Kent


More information about the Tutor mailing list