>>> from copy import copy
>>> a = OrderedSet([1,2,3])
>>> b = copy(a)
>>> print b
OrderedSet()
I know an OrderedSet isn't mutable, so copy() doesn't really make that much sense, but other non mutable types (strings) return the same object when calling copy on them:
>>> id("a") == id(copy("a"))
True
It just caught me out as I was duck typing between lists and OrderedSets
I know an OrderedSet isn't mutable, so
copy()
doesn't really make that much sense, but other non mutable types (strings) return the same object when calling copy on them:It just caught me out as I was duck typing between lists and OrderedSets