Continuing indentation
Ben Finney
ben+python at benfinney.id.au
Wed Mar 2 19:30:04 EST 2016
(Igor, your “From” field doesn't contain a name for you. Can you put
your name, e.g. “Igor Whateverisyoursurname”, in the “From” field?)
codewizard at gmail.com writes:
> How about:
>
> continue_playing = (
> some_condition and
> some_other_condition and
> some_final_condition
> )
>
> if continue_playing:
> play_bingo()
>
> or:
>
> play_conditions = [
> some_condition,
> some_other_condition,
> some_final_condition,
> ]
>
> if all(play_conditions):
> play_bingo()
Yes, these are good. When a condition is too complex, it makes sense to
assign a name to it. It can even help to pull out a coherent part of the
complex condition and assign a name to that::
play_conditions = [
some_other_condition,
some_extra_condition,
(some and compound and condition)]
if some_condition and all(play_conditions):
play_bingo()
--
\ “Perchance you who pronounce my sentence are in greater fear |
`\ than I who receive it.” —Giordano Bruno, burned at the stake by |
_o__) the Catholic church for the heresy of heliocentrism, 1600-02-16 |
Ben Finney
More information about the Python-list
mailing list