[Python-ideas] Optional static typing -- the crossroads
Guido van Rossum
guido at python.org
Fri Aug 15 19:36:50 CEST 2014
On Fri, Aug 15, 2014 at 10:19 AM, Petr Viktorin <encukou at gmail.com> wrote:
> On Fri, Aug 15, 2014 at 7:00 PM, Guido van Rossum <guido at python.org>
> wrote:
> > On Fri, Aug 15, 2014 at 9:48 AM, Petr Viktorin <encukou at gmail.com>
> wrote:
> >>
> >> On Fri, Aug 15, 2014 at 5:55 PM, Guido van Rossum <guido at python.org>
> >> wrote:
> >> ...
> >> >> Also... Does None magically mean NoneType in type definitions?
> >> >
> >> > Yes.
> >>
> >> This would mean either that `(None | None) is None`, or that (x |
> >> None) is not always "optional x".
> >> And if type objects grow any other common functionality, None will
> >> have to support that as well.
> >
> >
> > Perhaps None itself should not implement any of this, and the __ror__
> method
> > on ABCs should implement it. That way, None|Mapping and Mapping|None
> would
> > both work, yet None|None would still be the TypeError it is today.
>
> ... and that (x|None) does not always mean "optional x".
> Is this case special enough?
>
I'm not following. The proposal seems to be to add __or__ and __ror__
methods to type itself requiring the other argument to be also a type, or
the special case None (which is a value, not a type).
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140815/96355deb/attachment-0001.html>
More information about the Python-ideas
mailing list