Easy to handle sets
In python2.7, I got an error during installation, so I used python3.5
orderedset.py
# -*- coding: utf-8 -*-
from orderedset import OrderedSet
oset = OrderedSet([1, 2, 3])
oset2 = OrderedSet([3, 2, 1])
oset3 = OrderedSet([1, 2, 3, 4])
print (oset == oset2)
# False
print (oset <= oset2)
# True
#Whether it is a subset
print (oset.isorderedsubset(oset2))
# False
print (oset.isorderedsubset(oset3))
# True
oset = OrderedSet([1, 2, 3])
lst = [1, 2, 3]
tes = {1, 2, 3, 4}
print (oset == lst)
# True
print (oset <= tes)
# True
print (oset | lst)
# OrderedSet([1, 2, 3])
print (oset | tes)
# OrderedSet([1, 2, 3, 4])
Recommended Posts