Re: python programming

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jude DaShiell <jdashiel@xxxxxxxxxxxxxx> writes:

> unfortunate python requirement is the use of blank lines to end loops.  I 
> found substituting those blank lines with comments helps my readability 

Yes, I've known a couple of blind Python programmers who add a comment
at the close of a block.

while foo:
    doSomething()
    if blargh:
      doBlargh()
    #end if
#end while

But since you're already using emacs, it has lots of features that will
let you move through code.
I'll give both keybindings and emacs function names.  Of course, these
will only work in python-mode, but since smart indenting is already
working for you, I assume you're already using python-mode.

function name: py-beginning-of-block
keybinding: C-c C-u
Description: Move to the beginning of the current block.  E.G., if
you're in a loop body, jump to the for or while.

Function: py-end-of-block
keybinding: C-c C-q
description: jump to the end of the block.  E.G., if you're in a loop
body, go to where the closing brace would be in a "bracy" C-like
language.  This actually takes you to the last character of the block.
Play with it and get a feel for it.

function: py-beginning-of-statement
keybinding: C-c C-p
description: Go to the beginning of a simple (non-compound statement)
For compound statements, use the block movement commands described above.

function: py-end-of-statement
keybinding: C-c C-n
description: Go to the end of the simple statement.  It takes you to the
last character.

Function: py-beginning-of-def-or-class
keybinding: C-M-a
description: Move to the beginning of a class or function definition.

function: py-end-of-def-or-class
keybinding: C-M-e
description: move to the end (last character) of a class or function
definition

There are also some equivalent functions that will move you to the end
of something and then find the next newline.
For instance, py-end-of-block-bol will take you to the end of the block
and then past the next newline, so that point is at column 0 on the line
following the end of the block.  As far as I can tell, there are no
keybindings for those, but you could always make your own.

python-mode has lots of useful stuff.  I'm just scratching the surface.
I've had to learn all this by playing around and looking at python-mode
source, so hopefully I've pointed someone in the right direction, as
opposed to misdirecting them!
In my experience, emacs is hands-down the best way for a blind
person to write Python on Linux.  We need a really good tutorial for it.
Maybe this is a start.

-- Chris
_______________________________________________
Speakup mailing list
Speakup@xxxxxxxxxxxxxxxxx
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup





[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux