[Python-ideas] Enhancing dict.values
Joao S. O. Bueno
jsbueno at python.org.br
Sat May 28 16:15:50 EDT 2016
So, apart from whatever idea you find more suitable,
as I was playing around with a module for dictionary utils just this week,
I made a proof of concept thingy that uses context managers and import from -
Whoever want to try it is welcome, of course:
(env)[gwidion at localhost tmp30]$ pip install extradict
...
Successfully installed extradict-0.1.9
(env)[gwidion at localhost tmp30]$ python
...
>>> from extradict import MapGetter
>>> a = dict(b="test", c="another test")
>>> with MapGetter(a) as a:
... from a import b, c
...
>>> print (b, c)
test another test
----------
For the time being it works as a naive implementation monkey patching
"__import__" -
When (and if) I get a proper thing using the importlib machinery , I
will upgrade
"extradict" to 0.2
On 28 May 2016 at 15:03, David Mertz <mertz at gnosis.cx> wrote:
> Worrying about how many .getmany() is seems silly. As Guido notes, it
> follows the pattern of .fetchmany() in the DBAPI. That "many" might be one,
> or even zero, which is fine.
>
> On May 28, 2016 3:23 AM, "Nathan Schneider" <neatnate at gmail.com> wrote:
>>
>>
>>
>> On Sat, May 28, 2016 at 2:41 AM, Greg Ewing <greg.ewing at canterbury.ac.nz>
>> wrote:
>>>
>>> Steven D'Aprano wrote:
>>>
>>>> "getmany" doesn't tell you, many of what?
>>>
>>>
>>> I think the idea is that it would get the same kind
>>> of things that get() gets, i.e. items by their keys.
>>>
>>>
>>
>> My slight hesitation about "many" is that it's a subjective quantity. (Are
>> 2 or 3 keys enough to count as "many"?)
>>
>> Another option would be 'geteach'—i.e., for each key provided, get a
>> value. Or 'getmult' (multiple), but that could be mistaken as
>> multiplication.
>>
>> Nathan
>>
>>
>> _______________________________________________
>> 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/
>
>
> _______________________________________________
> 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/
More information about the Python-ideas
mailing list