[issue39222] unittest.mock.Mock.parent is broken or undocumented

2020-01-05 Thread Florian Brucker
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

Re: Efficient binary search tree stored in a flat array?

2009-07-14 Thread Florian Brucker
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

Re: Clustering the keys of a dict according to its values

2008-11-15 Thread Florian Brucker
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

Clustering the keys of a dict according to its values

2008-11-14 Thread Florian Brucker
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

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Florian Brucker
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