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

2019-09-03 Thread Rob Cliffe via Python-ideas
On 29/08/2019 16:30:49, Chris Angelico wrote: isinstance(3, Union[str, int]) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.9/typing.py", line 764, in __instancecheck__ return self.__subclasscheck__(type(obj)) File "/usr/local/lib/python3.

[Python-ideas] Re: Custom string prefixes

2019-09-03 Thread Rhodri James
On 31/08/2019 12:31, Chris Angelico wrote: We call it a string, but a bytes object has as much in common with bytearray and with a list of integers as it does with a text string. You say that as if text strings aren't sequences of bytes. Complicated and restricted sequences, I grant you, but

[Python-ideas] Re: Custom string prefixes

2019-09-03 Thread Chris Angelico
On Tue, Sep 3, 2019 at 10:27 PM Rhodri James wrote: > > On 31/08/2019 12:31, Chris Angelico wrote: > > We call it a string, but a bytes object has as much in common with > > bytearray and with a list of integers as it does with a text string. > > You say that as if text strings aren't sequences of

[Python-ideas] Re: Add a `dig` method to dictionaries supporting the retrieval of nested keys

2019-09-03 Thread None via Python-ideas
Thanks everyone for the feedback and suggestions. I agree that there are many ways one could easily implement this (chaining, reduce, looping, etc.). I could continue to maintain a utility function and copy that around to all of code bases where I need this functionality, which is what I do to

[Python-ideas] Re: Add a `dig` method to dictionaries supporting the retrieval of nested keys

2019-09-03 Thread Paul Moore
On Tue, 3 Sep 2019 at 13:38, None via Python-ideas wrote: > I really believe that a nested key retrieval mechanism should be a > first-class offering of the standard library. It is extremely common in the > Python ecosystem to find developers working with data sets comprised of > nested data

[Python-ideas] Re: Add a `dig` method to dictionaries supporting the retrieval of nested keys

2019-09-03 Thread Anders Hovmöller
> On 3 Sep 2019, at 14:56, Paul Moore wrote: > > On Tue, 3 Sep 2019 at 13:38, None via Python-ideas > wrote: > >> I really believe that a nested key retrieval mechanism should be a >> first-class offering of the standard library. It is extremely common in the >> Python ecosystem to find de

[Python-ideas] Re: Custom string prefixes

2019-09-03 Thread Rhodri James
On 03/09/2019 13:31, Chris Angelico wrote: On Tue, Sep 3, 2019 at 10:27 PM Rhodri James wrote: On 31/08/2019 12:31, Chris Angelico wrote: We call it a string, but a bytes object has as much in common with bytearray and with a list of integers as it does with a text string. You say that as i

[Python-ideas] Re: Custom string prefixes

2019-09-03 Thread Chris Angelico
On Tue, Sep 3, 2019 at 11:19 PM Rhodri James wrote: > > On 03/09/2019 13:31, Chris Angelico wrote: > > On Tue, Sep 3, 2019 at 10:27 PM Rhodri James wrote: > >> > >> On 31/08/2019 12:31, Chris Angelico wrote: > >>> We call it a string, but a bytes object has as much in common with > >>> bytearray

[Python-ideas] Re: Add a `dig` method to dictionaries supporting the retrieval of nested keys

2019-09-03 Thread James Livermont via Python-ideas
It seems most of the folks on this thread have similar feelings on this, so I will drop this idea. We'll probably standardize on using glom for now. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le

[Python-ideas] Re: Custom string prefixes

2019-09-03 Thread Rhodri James
On 03/09/2019 15:27, Chris Angelico wrote: On Tue, Sep 3, 2019 at 11:19 PM Rhodri James wrote: On 03/09/2019 13:31, Chris Angelico wrote: On Tue, Sep 3, 2019 at 10:27 PM Rhodri James wrote: On 31/08/2019 12:31, Chris Angelico wrote: We call it a string, but a bytes object has as much in c

[Python-ideas] Re: Custom string prefixes

2019-09-03 Thread Chris Angelico
On Wed, Sep 4, 2019 at 12:43 AM Rhodri James wrote: > > On 03/09/2019 15:27, Chris Angelico wrote: > > On Tue, Sep 3, 2019 at 11:19 PM Rhodri James wrote: > >> > >> On 03/09/2019 13:31, Chris Angelico wrote: > >>> On Tue, Sep 3, 2019 at 10:27 PM Rhodri James wrote: > > On 31/08/2019 12

[Python-ideas] Re: Add a `dig` method to dictionaries supporting the retrieval of nested keys

2019-09-03 Thread Michael Foord
ConfgObj used to have a similar method I believe. From fetching a value from a nested section by supplying the full path (as an iterable I believe). Michael On Tue, 3 Sep 2019 at 15:36, James Livermont via Python-ideas < python-ideas@python.org> wrote: > It seems most of the folks on this thread

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

2019-09-03 Thread Philippe Prados
With my implementation, I can check assert int | None == None | int is true Le lun. 2 sept. 2019 à 13:32, Ivan Levkivskyi a écrit : > On Thu, 29 Aug 2019 at 23:48, Guido van Rossum wrote: > >> On Thu, Aug 29, 2019 at 3:33 PM Chris Angelico wrote: >> >>> On Fri, Aug 30, 2019 at 8:28 AM Guido va

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

2019-09-03 Thread Philippe Prados
Hello, I propose to resume all the arguments (I add my remarks in italic) and major questions. Add a new operator for `Union[type1|type2]` ? - CONS: This is not a new proposal. If I recall correctly, it was proposed way back at the very beginning of the type-hinting discussion, and the

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

2019-09-03 Thread Ricky Teachey
Regarding the discussion about using the tilde operator (an idea which has grown on me a bit): Would it help, for the purpose of alerting the user to potential backwards compatibility issues, to add a *second* dunder method, __optional__, or perhaps __tilde__. to the tilde operator resolution ord

[Python-ideas] Re: Custom string prefixes

2019-09-03 Thread Andrew Barnert via Python-ideas
On Sep 3, 2019, at 06:17, Rhodri James wrote: > >> On 03/09/2019 13:31, Chris Angelico wrote: >>> On Tue, Sep 3, 2019 at 10:27 PM Rhodri James wrote: >>> On 31/08/2019 12:31, Chris Angelico wrote: We call it a string, but a bytes object has as much in common with bytearray and wi

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

2019-09-03 Thread Andrew Barnert via Python-ideas
On Sep 2, 2019, at 23:50, Philippe Prados wrote: > > Add a new operator for `Union[type1|type2]` ? Hold on. Are you proposing `Union[t1 | t2]` as a new spelling for `Union[t1, t2]`? That seems pointless. I thought you were proposing just `t1 | t2`, which seems a whole lot more useful (and no m

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

2019-09-03 Thread Andrew Barnert via Python-ideas
On Sep 2, 2019, at 23:50, Philippe Prados wrote: > > Like Kotlin, add a new `?` operator to use syntax like `int?` ou `?int` ? > CONS: It’s not compatible with IPython and Jupyter Lab `?smth` displays help > for symbol `smth` > CONS: With default arguments, `?=` looks... not great > def f(source

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

2019-09-03 Thread Steven D'Aprano
On Thu, Aug 29, 2019 at 06:20:55PM +0100, Rob Cliffe via Python-ideas wrote: > >isinstance(x, str | int) ==> "is x an instance of str or int" > > Er, is that necessary when you can already write > isinstance(x, (str, int)) It's not *necessary* it's just nicer. -- Steven ___

[Python-ideas] Re: Adding support for adequately tagging AIX (pep425) to support distributed wheels

2019-09-03 Thread Greg Price
It sounds like you may be asking about two different things: * adding more distinct platform tags for wheels to use for AIX, indicating... a minimum OS level, if I'm connecting the dots correctly. This would be like what PEP 513 did with `manylinux1` for Linux, and PEP 571 is doing for the new-and

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

2019-09-03 Thread Andrew Barnert via Python-ideas
On Sep 3, 2019, at 19:45, Steven D'Aprano wrote: > > On Thu, Aug 29, 2019 at 06:20:55PM +0100, Rob Cliffe via Python-ideas wrote: > >>> isinstance(x, str | int) ==> "is x an instance of str or int" >> >> Er, is that necessary when you can already write >> isinstance(x, (str, int)) > > It's not