[Python-Dev] Experiences with Creating PEP 484 Stub Files
Phil Thompson
phil at riverbankcomputing.com
Wed Feb 10 13:01:55 EST 2016
More information about the Python-Dev mailing list
Wed Feb 10 13:01:55 EST 2016
- Previous message (by thread): [Python-Dev] Experiences with Creating PEP 484 Stub Files
- Next message (by thread): [Python-Dev] Experiences with Creating PEP 484 Stub Files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10 Feb 2016, at 5:52 pm, Guido van Rossum <guido at python.org> wrote: > > 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). That should do it, thanks. A followup question... Is... def foo(bar: str = Optional[str]) ...valid? In other words, bar can be omitted, but if specified must be a str or None? Thanks, Phil
- Previous message (by thread): [Python-Dev] Experiences with Creating PEP 484 Stub Files
- Next message (by thread): [Python-Dev] Experiences with Creating PEP 484 Stub Files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list