Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

This is not a bug, it is normal handling of `and` and `or` operators since 
Python 1.5 and possibly older.

The `and` and `or` operators are *short-cut* operators. This is intentional 
design, so we can write things like:

    if mylist and mylist[0] == value:

the `mylist[0] == value` expression is only evaluated if `mylist` is a truthy 
value.

This is all documented here:

https://docs.python.org/3/reference/expressions.html#boolean-operations

----------
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42394>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to