Colons, indentation and reformatting.

Neil Cerutti horpner at yahoo.com
Tue Jan 9 08:16:18 EST 2007


On 2007-01-09, Leif K-Brooks <eurleif at ecritters.biz> wrote:
> Paddy wrote:
>> Thinking about it a little, it seems that a colon followed by
>> non-indented code that has just been pasted in could also be
>> used by a Python-aware editor as a flag to re-indent the
>> pasted code.
>
> How would it reindent this code?
>
> if foo:
> print "Foo!"
> if bar:
> print "Bar!"
>
> Like this?
>
> if foo:
>      print "Foo!"
> if bar:
>      print "Bar!"
>
> Or like this?
>
> if foo:
>      print "Foo!"
>      if bar:
>          print "Bar!"

That's the key issue. The colon gives the editor an easy clue
where a block starts, but the there's no simply way to determine
where the block is supposed to end.

-- 
Neil Cerutti
Remember in prayer the many who are sick of our church and community. --Church
Bulletin Blooper



More information about the Python-list mailing list