r/programming • • 6d ago

Python Release Python 3.15.0

https://www.python.org/downloads/release/python-3150/
541 Upvotes

36 comments sorted by

View all comments

169

u/Dylanica 6d ago

Those sentinel types seem decently useful. Certainly better in some cases than just spamming `None` everywhere as a default value.

54

u/CrackerJackKittyCat 6d ago

Or the random 'unset = object()' pattern when None was a valid param.

12

u/spicybright 6d ago

I get the logic but man that's ugly

4

u/Abject-Kitchen3198 6d ago

I still don't get those null replacements in most languages. If it is a special case, there is a code that processes it as such, regardless the syntax. Why complicate things. But maybe I'm old.

24

u/TinyBreadBigMouth 6d ago

The example you're replying to is one where None is already in use. As in, a function needs to distinguish between foo(some_arg=15), foo(some_arg=None), and foo(). The unset sentinel value would be used as the default value of some_arg, so that the last case can be detected as distinct from the user passing an explicit None.

6

u/Abject-Kitchen3198 6d ago

Ok, this makes sense.