On 12/05/2026 00:39, Chris Angelico via Python-list wrote:
On Tue, 12 May 2026 at 09:35, Chris Angelico <[email protected]> wrote:
On Tue, 12 May 2026 at 09:06, Rob Cliffe via Python-list
<[email protected]> wrote:
I've read PEP 661 and I have a question - can anybody answer it?
The PEP makes clear that any call to sentinel() will return a fresh
sentinel object - even if it is called twice with the same string parameter.
It states that sentinel objects have two public attributes: __name__ and
__module__.
It also states that pickling and unpickling a sentinel will return the
same object:
MISSING = sentinel('MISSING')
assert pickle.loads(pickle.dumps(MISSING)) is MISSING
  betw
Oh, and to clarify: both PEP 661 and the active docs at
https://docs.python.org/3.15/library/functions.html#sentinel do
describe the behaviour of pickling, defining exactly why you can't get
the confusion you're describing.

ChrisA
Well, I've read that doc and re-read the PEP, and AFAICS nowhere does it say clearly/explicitly that trying to create 2 sentinel objects with the same string will raise an Exception, nor what that Exception will be (which would be useful to know - I can't guess it).
Assuming that this is the case, I think the doc should be clear about it.
I guess you MIGHT infer it from reading between the lines (if you're smarter than me 🙂).
Rob Cliffe

--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to