You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently (ordered-set 4.1.0), OrderedSet removes duplicates when both creating an OrderedSet with duplicates or when adding a duplicate element to an existing OrderedSet:
>>> s = OrderedSet([1, 1, 2, 3, 2])
>>> s
OrderedSet([1, 2, 3])
>>> s.add(1)
0
>>> s
OrderedSet([1, 2, 3])
What I'd like is an option, say FailOnDuplicate, that would raise an exception, say ValueError, when an OrderedSet is created with duplicate elements. That is, both
s = OrderedSet([1, 1, 2, 3, 2], FailOnDuplicate=True)
and
s = OrderedSet([1, 2, 3])
s.add(1)
should raise ValueError.
I realize that the Python built-in *set and frozenset have the same behavior. I think adding a similar option to set and frozenset would also be useful.
The text was updated successfully, but these errors were encountered:
Currently (ordered-set 4.1.0), OrderedSet removes duplicates when both creating an OrderedSet with duplicates or when adding a duplicate element to an existing OrderedSet:
What I'd like is an option, say FailOnDuplicate, that would raise an exception, say ValueError, when an OrderedSet is created with duplicate elements. That is, both
and
should raise ValueError.
I realize that the Python built-in *set and frozenset have the same behavior. I think adding a similar option to set and frozenset would also be useful.
The text was updated successfully, but these errors were encountered: