Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197775

Coming In Python 3.15: Sentinel Values

From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups comp.lang.python
Subject Coming In Python 3.15: Sentinel Values
Date 2026-05-11 00:17 +0000
Organization A noiseless patient Spider
Message-ID <10tr770$omms$1@dont-email.me> (permalink)

Show all headers | View raw


A new feature coming in Python 3.15 is the “sentinel” class, useful
for creating custom values to mark the end of sequences of items, that
kind of thing
<https://docs.python.org/3.15/library/functions.html#sentinel>,
<https://peps.python.org/pep-0661/>.

For those times when a simple “None” marker element is not sufficient,
this will be very convenient.

However, one limitation is that you cannot subclass the “sentinel”
class. I wonder why not? Consider this behaviour, from the PEP:

    Sentinel objects are “truthy”, i.e. boolean evaluation will result
    in True. This parallels the default for arbitrary classes, as well
    as the boolean value of Ellipsis. This is unlike None, which is
    “falsy”.

Suppose you want a sentinel to be “falsy”? The obvious way would be to
subclass it and override the __bool__ method accordingly. But this is
not allowed. The PEP goes into a lot of detail about the design
rationale in other areas, but not this one.

Back to comp.lang.python | Previous | NextNext in thread | Find similar


Thread

Coming In Python 3.15: Sentinel Values Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-11 00:17 +0000
  Re: Coming In Python 3.15: Sentinel Values Paul Rubin <no.email@nospam.invalid> - 2026-05-10 21:01 -0700
    Re: Coming In Python 3.15: Sentinel Values Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-11 06:24 +0000
      Re: Coming In Python 3.15: Sentinel Values Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-05-11 07:13 +0000
  Re: Coming In Python 3.15: Sentinel Values Tim Daneliuk <info@tundraware.com> - 2026-05-11 19:51 -0500
    Re: Coming In Python 3.15: Sentinel Values Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-12 02:42 +0000
      Re: Coming In Python 3.15: Sentinel Values Tim Daneliuk <info@tundraware.com> - 2026-05-12 09:52 -0500
    Re: Coming In Python 3.15: Sentinel Values Paul Rubin <no.email@nospam.invalid> - 2026-05-12 01:03 -0700
      Re: Coming In Python 3.15: Sentinel Values Tim Daneliuk <info@tundraware.com> - 2026-05-12 09:54 -0500

csiph-web