this post was submitted on 24 Apr 2025
62 points (94.3% liked)

Python

7095 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] sugar_in_your_tea@sh.itjust.works 5 points 3 weeks ago* (last edited 3 weeks ago)

"Many" isn't the same as "most," though I don't think there's any way to know what "most" is.

But here's my reason for agreeing w/ the OP:

  • not x checks both None and emptiness, which is usually desired
  • len(x) == 0 will raise an exception if x is null
  • with type hinting, those should be the only two reasonable options

It's nice that it's slightly faster, though performance has absolutely nothing to do w/ my preference, though it does have something to do with my preference for avoiding exceptions for non-exceptional cases.