And with libraries like pip install funcoperators or pip install infix, you can even write it infix :D

from funcoperators import infix
@infix
def superop(d1, sc):
    return {k: (v *superopp* sc) for k, v in d1.items()}

print({'a': 8} *superop* 5)


Le mer. 31 oct. 2018 à 18:35, Vladimir Filipović <hemflit@gmail.com> a écrit :
Julien, would I be correct if I summarized the changes you have in
mind like this:

for dictionaries d1 and d2,
non-Mapping ("scalar") sc,
binary operation ⊛,
and unary operation 𝓊 (such as negation or abs()):

d1 ⊛ sc == {k: (v ⊛ sc) for k, v in d1.items()}
sc ⊛ d1 == {k: (sc ⊛ v) for k, v in d1.items()}
𝓊(d1) == {k: 𝓊(v) for k, v in d1.items()}
d1 ⊛ d2 == {k: (d1[k] ⊛ d2[k]) for k in d1.keys() & d2.keys()}
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/