Open jfine2358 opened 6 years ago
The thing about None
is that it may have another meaning that you might actually want to pass down e.g. post_processor=None
to me would intuitively indicate - "do not do any post-processing", not "defer to the default post-processor". I find arg = deferred
to be more explicit in its intent.
The one problem I can think of with deferred = object()
is that (I think) is that if somehow a deferred object is serialized and deserialized (e.g. when doing multiprocessing) it will no longer be equal to the "deferred" object that lives in the module. Maybe class deferred: pass
is the way to go?
Perhaps provide Defer = None
, for those who want it. This would allow them to both provide the value and the specific semantic intent.
T.S. Eliot says [every] cat must have THREE DIFFERENT NAMES (see https://allpoetry.com/The-Naming-Of-Cats).
This would also allow us to proceed with coding, while keeping this issue open.
The "gotcha" I see with Defer = None
is that people may not realize that having arg = None
actually means "defer to default value in lower-level function" - which could cause bugs in cases where "None" is used to mean something else (as with the postprocessing example). Another poet once said: "There should be one-- and preferably only one --obvious way to do it."
Would you be ok with class Defer: pass
?
Well, that's not a problem until we have a deferral module. So let's get the module written, and then revisit. I didn't expect or intend this to become a rabbit hole.
ok
Current code has
deferred = object()
as the sentinel. Sometimes current practice isNone
. I thought subclassingNone
might give the best of both worlds. But that can't be done: see my post https://mail.python.org/pipermail/python-ideas/2018-July/052366.html