-
Couldn't load subscription status.
- Fork 51
Open
Description
Since OrderedSet supports indexing, it's natural to assume that assignments and del would work as well, but they don't:
>>> s = OrderedSet(['foo'])
>>> s[0]
'foo'
>>> s[0] = 'bar'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'OrderedSet' object does not support item assignment
>>> del s[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'OrderedSet' object doesn't support item deletionThere's an easy workaround for del (s.remove(s[0])), but not for item assignments. As far as I can tell, there is no way to reorder items at all, so it's impossible to replace an element with another one (while preserving its index).
Metadata
Metadata
Assignees
Labels
No labels