Jelle Zijlstra writes:

 > In fact, `typing.Optional` means that something can be None, *not*
 > that it is an optional argument.

You're missing my point.  Yes, the *implementation* is that the object
can be None.  But that's far more clearly expressed by Union[T, None]
if that's what you *mean*, and it only costs 3 characters.  Optional
clearly was intended to mean that this type is for use in optional
arguments.

Having "Optional" at all may have been a bad choice, since (1) it is
redundant given you still need to specify "= None" to actually make it
optional, and (2) usually shouldn't be used for optional arguments
that don't default to None (because in such cases None usually isn't
an acceptable argument).  I am persuaded of that now: it doesn't
express the idea "this type is for use in optional formal arguments".

But I am convinced by arguments about the *language* (including type
expressions) that are about *what it expresses*, as in the paragraph
above (natural language) or your example function f (code example).
Arguments about what something *is* in the implementation, or vague
statements that things "could" be misinterpreted aren't terribly
helpful to me, YMMV.  And I think they lead to bad decisions about the
language.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LLHRUM3CNBLVAX7VCFTZ6ZUPBVEXNBS7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to