Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-13 Thread Jonathan Fine
Hi Brice Good comment. I liked it. Not badly off-topic I think, because it looks to be an interesting work-around for the original problem. You wrote > But for dataclasses, I'd find it quite useful to have > {**my_data_class} > be a shortcut to > {**dataclasses.asdict(my_data_class)} How about w

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-13 Thread Brice Parent
Le 13/09/2018 à 10:07, Jonathan Fine a écrit : Now for my opinions. (Yours might be different.) First, it is my opinion that it is not reasonable to insist that the argument after ** must be a mapping. All that is required to construct a dictionary is a sequence of (key, value) pairs. The dict(i

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-13 Thread Jonathan Fine
Someone wrote: Granted, my only strong argument is that the ** unpacking operator depends on this method to do its job, and it's currently alone amongst Python's operators in depending on a non-dunder to do so I like this argument. And I think it's important. Here's some background fa

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-12 Thread Michael Selik
The dict keys method has other benefits beyond iteration. For example, it provides a set-like interface. On Wed, Sep 12, 2018, 10:50 PM Elias Tarhini wrote: > On Wed, Sep 12, 2018 at 4:42 PM Michael Selik wrote: > >> You want to have a Mapping that does not supply a keys method? What use >> cas

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-12 Thread Elias Tarhini
On Wed, Sep 12, 2018 at 4:42 PM Michael Selik wrote: > You want to have a Mapping that does not supply a keys method? What use > case motivated your proposal? > Yes, my proposal was to consider allowing __iter__() to subsume keys() entirely, for the reasons outlined in my second email -- which

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-12 Thread Michael Selik
Elias, I'm a little confused about what you're suggesting. You want to have a Mapping that does not supply a keys method? What use case motivated your proposal? On Mon, Sep 10, 2018, 7:04 PM Elias Tarhini wrote: > This has been bouncing around in my head for a while regarding the > requisite ke

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-12 Thread Alex Walters
> -Original Message- > From: Python-ideas list=sdamon@python.org> On Behalf Of Serhiy Storchaka > Sent: Tuesday, September 11, 2018 2:54 AM > To: python-ideas@python.org > Subject: Re: [Python-ideas] __iter__(), keys(), and the mapping protocol > > 11.09

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-10 Thread Serhiy Storchaka
11.09.18 05:04, Elias Tarhini пише: This has been bouncing around in my head for a while regarding the requisite keys() method on mappings: How come the ** unpacking operator, a built-in language feature, relies on a non-dunder to operate? To me, I mean to say, requiring that classes impleme

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-10 Thread Alex Walters
- > From: Python-ideas list=sdamon@python.org> On Behalf Of Elias Tarhini > Sent: Monday, September 10, 2018 10:04 PM > To: Python-Ideas > Subject: [Python-ideas] __iter__(), keys(), and the mapping protocol > > This has been bouncing around in my head for a while re

[Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-10 Thread Elias Tarhini
This has been bouncing around in my head for a while regarding the requisite keys() method on mappings: How come the ** unpacking operator, a built-in language feature, relies on a non-dunder to operate? To me, I mean to say, requiring that classes implement keys() – a method whose name is totall