On 29.03.2014 22:55, Johannes Bauer wrote:
>>> if (a is not None) or (b is not None):
>
> Yes, probably. I liked the original, too. If I were writing the code,
> I'd probably try to aim to invert the condition though and simply do
>
> if (a is None) and (b is None)
>
> Which is pretty easy to understand for even a rookie programmer.
Let me expand on that thought one or two more sentences: Although it may
seem really trivial, inversions ("not") in my opinion can really make
code unreadable. One thing that I regularly see when peer-reviewing code
is something like:
if not feature_disabled:
or one that I've seen in-field (modulo the programming language and the
variable names):
if (not no_delayed_commit) and (not data_unchanged):
instead of:
if immediate_commit and data_changed:
Enough of my two cents for today :-)
Cheers,
Johannes
--
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <[email protected]>
--
https://mail.python.org/mailman/listinfo/python-list