[issue35123] Add style guide for sentinel usage

Robert Wright report at bugs.python.org
Wed Nov 7 06:48:33 EST 2018


Robert Wright <madman.bob at hotmail.co.uk> added the comment:

Perhaps there's confusion over what I mean by "style guide". I'd happily take Steven's message *as* the style guide. Or, at the very least, the clarification that sentinels are to be thought of as constants.

It's one of those things that's obvious once mentioned, but might not be thought of when you're using them.

Though Eric does raise an interesting point about C sentinels. Something like:

kwargs = {}

if mode is not _MISSING:
  kwargs.update(mode=mode)

return open(name, "foo", **kwargs)

would work a bit better with multiple arguments, but it's still not great.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35123>
_______________________________________


More information about the Python-bugs-list mailing list