[Novalug] Why Python

Stuart D. Gathman stuart@gathman.org
Sat Aug 3 13:02:33 EDT 2013


On Sat, 3 Aug 2013, James Ewing Cottrell III wrote:

> Comments Inline.
>
> On 8/1/2013 11:01 AM, The Doctor wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 08/01/2013 01:21 AM, James Ewing Cottrell III wrote:
>>
>>> What does the '%' command do in vi(m) when editing Python? Or
>>> Ruby?
>>
>> It works well for finding matched parenthesis and hard braces in
>> Python.  I use it a fair amount.
>
> Yes, but in Python, as well as Ruby, the {} chars that delimit block are
> gone, and in Ruby, they are Words like "end". Also, the newer (in vim,
> not in vi) algorithm seems to be "if not on a mating char, search
> forward on the line until you find one.

Vim understands python blocks just fine (e.g. [[ - goto beginning of
block and ]] - goto end of block).  Set vim to expand tabs to
spaces when editing python.  Python2 tabnanny checks that the grammar reads
the same for all possible tab expansions, and python3 refuses to run
a file with "ambiguous" tabs.  (ASCII tab is by definition 8, but I've
guess we've lost the battle with all the programmers setting tab to some
random value in their editor.)  The easiest way to ensure this is to
either use all tabs for indenting, or all spaces for indenting.  Since 
I hate large indent steps, I just expand tab to spaces.

There are many places where tab does not need to be expanded to avoid 
"ambiguity", e.g. comment lines, and after the leading whitespace.
While this could be optimized, it doesn't save enough chars to be worth it.

-- 
 	      Stuart D. Gathman <stuart@gathman.org>
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.



More information about the Novalug mailing list