Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103897 > unrolled thread
| Started by | Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> |
|---|---|
| First post | 2016-03-02 22:12 +0100 |
| Last post | 2016-03-02 22:12 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Continuing indentation Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2016-03-02 22:12 +0100
| From | Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> |
|---|---|
| Date | 2016-03-02 22:12 +0100 |
| Subject | Re: Continuing indentation |
| Message-ID | <mailman.115.1456953171.20602.python-list@python.org> |
On 3/2/2016 21:43, Skip Montanaro wrote:
> Running flake8 over some code which has if statements with multiple
> conditions like this:
>
> if (some_condition and
> some_other_condition and
> some_final_condition):
> play_bingo()
>
> the tool complains that the indentation of the conditions is the same
> as the next block. In this particular case, the overall conditions
> are too long to string together on a single line. I tried placing a
> second space after the if keyword:
>
> if (some_condition and
> some_other_condition and
> some_final_condition):
> play_bingo()
>
> which solves the matching indentation problem, but creates a multiple
> spaces after keyword problem. My guess is that adding a space after
> the open paren would provoke a message as well.
>
> I use GNU Emacs as my text editor, and its python mode. I'm pretty
> happy with everything (been using it in its current state for several
> years). Aside from manually or configure-ologically suppressing E129,
> is there a better way to break lines I'm missing which will make
> flake8 happy?
>
I don't know about flake8, but pep8 says all these are acceptable though
the first version (like yours) has the readability problem flake8
complains about:
# No extra indentation.
if (this_is_one_thing and
that_is_another_thing):
do_something()
# Add a comment, which will provide some distinction in editors
# supporting syntax highlighting.
if (this_is_one_thing and
that_is_another_thing):
# Since both conditions are true, we can frobnicate.
do_something()
# Add some extra indentation on the conditional continuation line.
if (this_is_one_thing
and that_is_another_thing):
do_something()
Maybe version 2 would make the tool happy?
Back to top | Article view | comp.lang.python
csiph-web