Re: Seeking feedback from speech users of Python

  • From: Veli-Pekka Tätilä <vtatila@xxxxxxxxxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sat, 15 Dec 2007 13:22:32 +0200

Hello Jamal,
I haven't used the scripts myself and don't program in Python very much,
however I do use braces in many langs. I definitely recommend you to
support at least the Allman style, which makes the braces line up and
indents the code within them. I use it with magnification, since it
makes it easy to scan the left and right braces because my magnified
view port is very very small. I recall several Braille users stating the
same thing, too, when this came up the last time. I also comment ending
braces to give more context with speech and sometimes beginning braces
for short in-line docs, so I would advice you to pay attention to where
such comments end up in the Python code. Auto including them as doc
strings for methods might be cool, if no doc string is given. Here's an
example block of both beginning and ending comments:

sub rgb2hsl
{ # Given an RGB triplet each in 0 .. 255 convert to SL in 0 .. 255 and
H in 0 .. 360.
        # code 
} # sub 

As for other variants, there's something called the Whitesmiths style,
which is like Allman except that it indents the braces themselves so
that the code lines up with the braces. This is used in SymbianOS
programming to my knowledge.

As to compact variants some people make the elsif in an if, elsif,
elsif, else also line up with the previous right brace, which is called
cuddling the braces if I heard  my speech synth right the other day,
<smile>. Not sure how common this is, here's again a generic brace
example:

if(something) {
   some code
} elsif(other thing)
   some other code 
} else {
   default behavior
}

Yet another variant I use myself for short if, elsif, elsif structures
is putting the whole block in a single line immediately following the
if, elsif or else. This is mainly for switch-like constructs and I would
urge your code to be tolerant of this. Here's an example from an actual
program, warning regular expressions ahead:

if(/^\.(.+)$/) { $group = $1; } # Groups of sections, non-standard INI
extension.
elsif(/^\[([^[]+)\]$/) { $section = $1 } # Sections in groups.
elsif(/^(.+?)=(.+?)$/) { $tree->{$group}{$section}{$1} = $2;  } #
Key-val pair, add to struct now.
else                    { die "Invalid instrument file.\nLine: $_\n" }

PS: A funny confession: I don't find the PYthon style that bad magnified
and sometimes actually use a Perl module, which goes from Perl bbraces
to Python indentation via source filtering. ALl you have to do is to
say:
use Acme::Pythonic; 
at the beginning of your code, and the rest of the magic happens behind
the scenes automatically.

-- 
With kind regards Veli-Pekka Tätilä (vtatila@xxxxxxxxxxxxxxxxxxxx)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila

Jamal Mazrui wrote:
> 
> I have included an experimental feature in EdSharp
> http://www.EmpowermentZone.com/edsetup.exe
> 
> In seeking a more efficient way of managing the indentation requirement, I
> am trying a coding style called PyBrace, where the colon and indented
> block are replaced by a set of curly braces surrounding the block.
> Alt+Shift+LeftBracket (think of the brace character) turns either all or
> selected text into this style of code, which makes it easy to understand
> the structure with speech.
> 
> The inverse command is called PyDent, Alt+LeftBracket, which converts from
> PyBrace format to the equivalent indentation required by the Python
> interpreter.
> 
> PyBrace assumes that the opening brace will be at the end of the line of
> text that starts the block, and the closing brace will be on a line by
> itself.  Also, PyDent assumes that a single tab character is used for each
> level of indentation -- though I intend to support other indentation
> conventions as well if this approach seems productive.
> 
> I have been able to convert to and from PyBrace and run a Python script
> successfully (the Python fruit basket program).  If anyone else can try
> this approach, and let me know your results as well as any other ideas for
> improvement, that would be helpful.
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: