擅长:python、mysql、java
<p>将所有属性请求转发到内部集合:</p>
<pre><code>class PersistentSet(Persistent):
def __init__(self):
self.inner_set = set()
def __getattribute__(self, name):
try:
inner_set = Persistent.__getattribute__(self, "inner_set")
output = getattr(inner_set, name)
except AttributeError:
output = Persistent.__getattribute__(self, name)
return output
</code></pre>