You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
20 lines
460 B
Python
20 lines
460 B
Python
# Bug in 3.3 weakset
|
|
# Bug was not having a rule for 3.x "comp_for"
|
|
|
|
# RUNNABLE!
|
|
class WeakSet:
|
|
def __init__(self, data=None):
|
|
self.data = set(data)
|
|
|
|
def __iter__(self):
|
|
for item in self.data:
|
|
if item is not None:
|
|
yield item
|
|
|
|
def union(self, other):
|
|
return self.__class__(e for s in (self, other) for e in s)
|
|
|
|
a = WeakSet([1, 2, 3])
|
|
b = WeakSet([1, 3, 5])
|
|
assert list(a.union(b)) == [1, 2, 3, 5]
|