[Python-Dev] Experiences with Creating PEP 484 Stub Files
Guido van Rossum
guido at python.org
Wed Feb 10 12:52:23 EST 2016
On Wed, Feb 10, 2016 at 1:11 AM, Phil Thompson
<phil at riverbankcomputing.com> wrote:
> I understand now. The documentation, as it stands, is correct and consistent but (to me) the meaning of Optional is completely counter-intuitive. What you suggest with str = ... is exactly what I need. Adding a section to the docs describing that should clear up the confusion.
I tried to add some clarity to the docs with this paragraph:
Note that this is not the same concept as an optional argument,
which is one that has a default. An optional argument with a
default needn't use the ``Optional`` qualifier on its type
annotation (although it is inferred if the default is ``None``).
A mandatory argument may still have an ``Optional`` type if an
explicit value of ``None`` is allowed.
Should be live on docs.python.org with the next push (I don't recall
the delay, at most a day IIRC).
--
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev
mailing list