On 2/28/2017 1:48 PM, David Mertz wrote:
So it sounds like what you want is this:

    In [30]: class FrozenSet(frozenset):
        ...:     def pop(self):
        ...:         item = next(iter(self))
        ...:         return item, self-{item}
        ...:

    In [31]: a = FrozenSet({1,2,3,4,5})

    In [32]: a.pop()
    Out[32]: (1, frozenset({2, 3, 4, 5}))


I think I'm +1 on `frozenset` itself growing that method.

To me, 'pop' implies mutation. Tuples do not have a pop method, and it is not obvious to me that either tuples or frozensets should. What are the use cases that are not better served by converting to list or set?

--
Terry Jan Reedy

_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to