New to Python - block grouping (spaces)yhoni
alister.nospam.ware at ntlworld.com
Thu Apr 16 15:18:12 CEST 2015
On Thu, 16 Apr 2015 13:07:22 +0200, Antoon Pardon wrote:
> On 04/16/2015 12:43 PM, Steven D'Aprano wrote:
>> On Thursday 16 April 2015 20:09, Antoon Pardon wrote:
>>> I beg to differ. The most common occurence is a loop with a break
>>> condition in the middle I would prefer such a loop to be written as
>>> some code
>>> break_when condition:
>>> more code
>> That structure makes no sense to me. Why is the "break_when" *outside*
>> of the loop? Why does the "break_when condition" introduce a new block?
> How do you mean outside the loop? Do you consider the "else" outside the
> if statement?
>>> Actually I would prefer a more elaborate scheme but would be contend
>>> with a possibility like the above. IMO this is the most occuring
>>> pattern where the logical structure doesn't match the physical
>>> structure and it is not occuring relevantly less now.
>> Judging by the above example, I think it may be a good thing that
>> Python doesn't allow "more elaborate" indentation schemes.
>> do this do that
>> do something else important
>> and this
>> sometimes this
>> also this
>> but don't do this
>> unless today is Tuesday
>> # end loop
>> Simplicity is a virtue.
> As is argueing against a real position instead of making something up.
> Nobody is argueing for arbitrary indentation.
May I suggest that you give it a try for a month, perhaps re-writing a
small program you already have in a pythonic style (don't simply write c
in python) & see if your opinion changes.
if not then other suggestions that python is not a language of choice for
you may be appropriate.
be warned you may find it creates (or increases ) an extreme dislike for
C & other languages that require braces & semicolons, it did for me
(especially the semi-colon!)
If in any problem you find yourself doing an immense amount of work, the
answer can be obtained by simple inspection.
More information about the Python-list