PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

Marco Sulla Marco.Sulla.Python at gmail.com
Thu Mar 19 14:15:57 EDT 2020


On Thu, 19 Mar 2020 at 16:46, Peter J. Holzer <hjp-python at hjp.at> wrote:
> This is similar to algebraic expressions: Have you ever tried to read a
> mathematical paper from before the time the current notation (which we
> Long, convoluted
> sentences instead of what can now be written as a short formula.

...yes, and as an ex Physics student I have to say that short formulas
are completely unreadable, until someone explain them to you. Like
poetry.

> Would it be clearer in this case? I think so. Especially if you have
> several keys to extract.

Ok, but what is the use case? I mean, how much time you need more than
2, 3 keys?

In my Python implementation of frozendict, I'm doing a different
approach for have something as you want: implement the `set` API. For
example:

d = {
        'first_name': 'Frances',
        'last_name': 'Allen',
        'email': 'fallen at ibm.com'
}

d & ("first_name", "last_name") == {'first_name': 'Frances',
'last_name': 'Allen'}

https://github.com/Marco-Sulla/python-frozendict/commit/b2628e14f3275c6ba488dde220023c14f6a8435a

> you can't easily extend a
> language which is too simple.

So you can't easily extend Python? ^^


More information about the Python-list mailing list