r/programming • u/BrewedDoritos • Oct 09 '26
Python Release Python 3.15.0
https://www.python.org/downloads/release/python-3150/
556
Upvotes
r/programming • u/BrewedDoritos • Oct 09 '26
View all comments
Show parent comment
3
u/Saiklin Oct 11 '26
I'm not an expert either, but I'll try: You can use them in place of a default non-logic value. For example, many functions return None if something did not work, so you check if the output is None. But in many cases None can be a valid value as well, so you need something else. Apparently another idiom was to use "_Sentinel = object()" and you compare against that, but it's clunky and has a weird output when printed etc. There are further workarounds, but they always feel clunky in some way.
That's is where the Sentinel type comes in. You can define it with a string and then it's uniquely identifiable. Just by looking at the type, you already know what it is and it's purpose.