Snippet from CPy stdlib urlparse.py:
class Quoter(collections.defaultdict):
def __init__(self, safe):
"""safe: bytes object."""
self.safe = _ALWAYS_SAFE.union(safe)
You see, it doesn't call super().__init__()
. That's because it relies on __new__
to initialize base class automatically. Specifically for CPy, collections.defaultdict is at all native type, and to emulate its behavior we need __new__
.
Another testcase:
class Base:
def __new__(cls):
print("Base __new__")
class Sub(Base):
pass
o = Sub()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4