[Python-ideas] dict(default=int)
Ryan Gonzalez
rymg19 at gmail.com
Mon May 29 18:43:39 EDT 2017
Sometimes I feel that it would be neat of dict constructors (like proposed
previously in the thread) could also be chained, e.g.:
dict.ordered.default(int)(a=1, b=2)
--
Ryan (ライアン)
Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else
http://refi64.com
On May 29, 2017 2:06 PM, "Neil Girdhar" <mistersheik at gmail.com> wrote:
> A long time ago, I proposed that the dict variants (sorteddict,
> defaultdict, weakkeydict, etc.) be made more discoverable by having them
> specified as keyword arguments and I got the same feedback that the poster
> here is getting. Now, instead of moving these classes into dict, why not
> have a factory like
>
> dict.factory(values=None, *, ordered=True, sorted=False,
> has_default=False, weak_keys=False, weak_values=False, …)
>
> If prefers the keyword-argument as options to the keyword-argument as
> initializer magic, they can set:
>
> dict = dict.factory
>
> Best,
>
> Neil
>
> On Thursday, March 9, 2017 at 5:58:43 PM UTC-5, Chris Barker wrote:
>>
>>
>>
>> >If we really want to make defaultdict feel more "builtin" (and I don't
>>> see
>>> >any reason to do so), I'd suggest adding a factory function:
>>> >
>>> >dict.defaultdict(int)
>>>
>>
>>
>>> Nice.
>>>
>>
>> I agree -- what about:
>>
>> dict.sorteddict() ??
>>
>> make easy access to various built-in dict variations...
>>
>> -CHB
>>
>>
>> --
>>
>> Christopher Barker, Ph.D.
>> Oceanographer
>>
>> Emergency Response Division
>> NOAA/NOS/OR&R (206) 526-6959 voice
>> 7600 Sand Point Way NE (206) 526-6329 fax
>> Seattle, WA 98115 (206) 526-6317 main reception
>>
>> Chris.... at noaa.gov
>>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170529/27ec527d/attachment-0001.html>
More information about the Python-ideas
mailing list