A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-July/154686.html below:

[Python-Dev] PEP 572 and assert

[Python-Dev] PEP 572 and assert [Python-Dev] PEP 572 and assertBarry Warsaw barry at python.org
Tue Jul 17 15:58:42 EDT 2018
On Jul 17, 2018, at 12:18, MRAB <python at mrabarnett.plus.com> wrote:

> Why use len(...) == 0 instead of not(...)?
> 
>    assert not(subdirs := list(path.iterdir())), subdirs

Off-topic, but it’s a style thing.  Some style guides (and my personal preference) require to be more explicit when checking for empty sequences.  I’ll use a boolean test (e.g. `not` or false-iness) when the subject could be empty, None, or the empty string, and `len() == 0` when the subject is supposed to be a sequence.

-Barry


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180717/ee5a6c64/attachment.sig>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4