[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Dominik Vilsmeier
Andrew Barnert wrote: > On Aug 29, 2019, at 16:03, Dominik Vilsmeier [email protected] wrote: > > I never really understood the importance of > > Optional. Often it can be left out altogether and in other cases I find > > Union[T, None] more expressive (explicit) than Optional[T] (+ > > the

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Philippe Prados
Why not extend isInstance to : isinstance(object:Any,classinfo: Iterable | Union) ? Le ven. 30 août 2019 à 09:41, Dominik Vilsmeier a écrit : > Andrew Barnert wrote: > > On Aug 29, 2019, at 16:03, Dominik Vilsmeier [email protected] > wrote: > > > I never really understood the importanc

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Andrew Barnert via Python-ideas
On Aug 30, 2019, at 02:09, Philippe Prados wrote: > > Why not extend isInstance to : > > isinstance(object:Any,classinfo: Iterable | Union) ? How would you pass a single type? And once you allow a single type, you shouldn’t have to do anything special to allow a Union, because a Union is alre

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Philippe Prados
May be, with isinstance(object:Any,classinfo: Tuple | Union) ? it's possible to accept isinstance(anUnion, [Union]) # Force tuple for Union isinstance(aTuple, [Tuple] # Force Tuple isinstance(aStr, int | str) Correct ? Le ven. 30 août 2019 à 19:29, Andrew Barnert a écrit : > On Aug 30, 2019

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Andrew Barnert via Python-ideas
On Aug 30, 2019, at 11:26, Philippe Prados wrote: > > May be, with >> isinstance(object:Any,classinfo: Tuple | Union) ? > > it's possible to accept > > isinstance(anUnion, [Union]) # Force tuple for Union > isinstance(aTuple, [Tuple] # Force Tuple > isinstance(aStr, int | str) > > Correct ?

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Pasha Stetsenko
> I can’t think of any uses other than Optional. Also, in IPython and Jupyter Lab `?smth` displays help for symbol `smth`. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Andrew Barnert via Python-ideas
On Aug 30, 2019, at 18:40, Pasha Stetsenko wrote: >> I can’t think of any uses other than Optional. > > Also, in IPython and Jupyter Lab `?smth` displays help for symbol `smth`. Yeah, and probably more Python users regularly use IPython than, say, BASIC, so maybe a bit more potential for confu