On Fri, Feb 12, 2016 at 12:27 PM, Andrew Barnert via Python-ideas < email@example.com> wrote:
I look forward to it. Next time I need some variation of this, even if it *isn't* the same variation you end up building, the fact that there's a potential de facto standard for what to call the ".inv" or whatever still helps me, right?
yeah, though I'm not sure I like that name... (can't think of a better one right now, though).
But what I would like is for the "inverse" to be available as an object itself, so:
my_double_dict = DoubleDict( ( (1:'a'), (2:'b'), (3:'c) ) ) my_inverse = my_double_dict.inv
my_double_dict == 'a' my_inverse['a'] == 1
i.e you now have two objects, which are essentially the same object, but with inverse referencing semantics.
Note how I cleverly introduced a name for this object -- I think it more as doubling than inversing, or really a one-to-one mapping, but haven't thought of a clever name for from that...
And for my part, re-using a key on either side should simply write-over the existing item, just like a dict.
Also, even if nobody ever agrees to put this in the stdlib, the collections module linked to some outside recipes/modules like OrderedSet long before Nick and the other packaging guys started pushing the idea that it was a good idea for the stdlib in general. I think if this gets sufficient uptake, it deserves such a link. As you say, it's something many people end up building for themselves.
Python-ideas mailing list Pythonfirstname.lastname@example.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/