Grouping code by indentation - feature or ******?
Giovanni Bajo
noway at sorry.com
Sun Mar 27 03:55:36 EST 2005
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.
--
Giovanni Bajo
More information about the Python-list
mailing list