diff options
author | Guido van Rossum <guido@python.org> | 2016-02-10 17:48:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-02-10 17:48:58 (GMT) |
commit | e93b06a0a3255026802be19de249b3fdfe955b96 (patch) | |
tree | 9a25a8cd72ada9784e925877e9a2ea31c4104335 /Doc | |
parent | 48a583b1d83d9c44c9dd9facb9331737518d6618 (diff) | |
download | cpython-e93b06a0a3255026802be19de249b3fdfe955b96.zip cpython-e93b06a0a3255026802be19de249b3fdfe955b96.tar.gz cpython-e93b06a0a3255026802be19de249b3fdfe955b96.tar.bz2 |
Hopefully clarify the difference between Optional[t] and an optional argument.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/typing.rst | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 41f594e..12b5490 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -286,6 +286,13 @@ The module defines the following classes, functions and decorators: ``Optional[X]`` is equivalent to ``Union[X, type(None)]``. + 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. + .. class:: Tuple Tuple type; ``Tuple[X, Y]`` is the is the type of a tuple of two items |