擅长:python、mysql、java
<p>从Python 3.9开始<a href="https://docs.python.org/3/library/functions.html#classmethod" rel="nofollow noreferrer">^{<cd1>}</a>可以修饰其他描述符,如<code>property</code>。这样就可以创建“类属性”:</p>
<pre><code>class RealSet:
def __init__(self, intervals, *, canonicalize):
pass
@classmethod
@property
def EMPTY(cls):
return cls(tuple(), canonicalize=False)
@classmethod
@property
def UNIVERSE(cls):
return cls(((None, None),), canonicalize=False)
</code></pre>