New submission from Florian Brucker :
The "parent" attribute of unittest.mock.Mock is either broken or undocumented.
For example, on Python 3.7.4:
>>> from unittest.mock import Mock
>>> m = Mock(x=1, parent=2)
>>> m.x
1
>>> m.parent
Traceb
Douglas Alan wrote:
Thank you. My question wasn't intended to be Python specific, though.
I am just curious for purely academic reasons about whether there is
such an algorithm. All the sources I've skimmed only seem to the
answer the question via omission. Which is kind of strange, since it
Wow, thanks everybody! There's a lot to learn for me from these examples...
Enjoy your weekend!
Florian
Florian Brucker wrote:
Hi everybody!
Given a dictionary, I want to create a clustered version of it,
collecting keys that have the same value:
d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2
Hi everybody!
Given a dictionary, I want to create a clustered version of it,
collecting keys that have the same value:
d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3}
cluster(d)
{1:['a', 'c', 'd'], 2:['b', 'e'], 3:['f']}
That is, generate a new dict which holds for each value of the old
Are you sure? Is this for school?
Yes, I'm pretty sure (the values of the original dict are integers), and
no, this isn't for school :) If the We may assume ... made you think
so, I guess that's the way everybody formulates requirements after
having read to many math papers :D
If it is of