Repository navigation
Conversation
Sentinel objects can now be given a docstring with `sentinel(name, doc=...)`. The `__doc__` attribute of a sentinel object remains read-only.
Documentation build overview
4 files changed± builtins/functions.html± using/ios.html± whatsnew/3.16.html± whatsnew/changelog.html |
|
|
||
| PyObject *sentinel = sentinel_new_with_module( | ||
| &PySentinel_Type, name_obj, module_obj, repr_obj); | ||
| &PySentinel_Type, name_obj, module_obj, repr_obj, Py_None); |
There was a problem hiding this comment.
Probably we should replace PySentinel_New() with some new PySentinel_NewEx(), having new argument. Or introduce new C-API function to set __doc__ attribute.
There was a problem hiding this comment.
Yeah, I mentioned that in the issue (with the name PySentinel_NewWithDoc but I'll let you decide the name). Should I add it? I don't really know what the pros and cons of new C constructor vs a setter are...
|
I think it should not default >>> MISSING = sentinel("MISSING")
>>> MISSING.__doc__
'Create a unique sentinel object with the given name.'
>>>However with the current changes, nothing shows up >>> MISSING = sentinel("MISSING")
>>> MISSING.__doc__
>>>Edit: Just re-read the issue description. But still think it would be useful to have a default value for people not very familiar with sentinels |
Sentinel objects can now be given a docstring with
sentinel(name, doc=...). The__doc__attribute of a sentinel object remains read-only.docparameter tosentinel#162069