[Python-ideas] Dict(x, y) -> Dict(zip(x, y))
MRAB
python at mrabarnett.plus.com
Tue Feb 16 20:36:21 EST 2016
On 2016-02-17 01:05, Andrew Barnert wrote:
> On Feb 16, 2016, at 16:34, MRAB <python at mrabarnett.plus.com> wrote:
> >
> >> On 2016-02-16 23:48, Ian Foote wrote:
> >>> On 15/02/16 09:53, Andrew Barnert via Python-ideas wrote:
> >>>
> >>>
> >>> But what about a classmethod named constructor (with or without
> >>> keyword-only params, depending on how long the name is):
> >>>
> >>> dict.kv(keys=spam, values=eggs)
> >>> dict.from_keys_values(spam, eggs)
> > Going the other way it's "my_dict.items()", so perhaps "dict.from_items(spam, eggs)"?
>
> But items() is the inverse of the plain constructor, which takes an iterable of items. In other words, both items() and the constructor deal in a single iterable of zipped key-value pairs.
[snip]
Ah, of course! Obvious when you point it out...
More information about the Python-ideas
mailing list