Grouping code by indentation - feature or ******?
Terry Reedy
tjreedy at udel.edu
Sun Mar 27 12:14:34 EST 2005
"Giovanni Bajo" <noway at sorry.com> wrote in message
news:cyu1e.32621$zZ1.942071 at twister1.libero.it...
> Terry Reedy wrote:
>
>>> 3) Sometimes the structure of the algorithm is not the structure
>>> of the code as written, people who prefer that the indentation
>>> reflects the structure of the algorithm instead of the structure
>>> of the code, are forced to indent wrongly.
>>
>> Do you have any simple examples in mind?
>
> Yes. When I use PyQt (or similar toolkit), I would like to indent my
> widget
> creation code so that one indentiation level means one level down into
> the
> widget tree hierarchy:
>
> v = VBox(self)
> # sons of v indented here
> w = HBox(self)
> # sons of w here
> QLabel("hello", w)
> QLabel("world", w)
> QButton("ok", v)
>
> In fact, I am used to do this very thing in C++, and it helps readability
> a
> lot.
>
> I know I can add "if 1:" to do such a thing, but that's beyond the point.
> I'm
> just showing that there are simple and reasonable examples of cases where
> you
> would like to indent your code in different ways and you can't.
I would call the above an indication of the structure of the output rather
than of the algorithm, which is quite linear. Nonetheless, I can see it as
a reasonable alternate reason for wanting to indent. Thanks for the
response.
Terry J. Reedy
More information about the Python-list
mailing list