Python Deprecation Warnings with Monostate __new__ — Can someone explain why?
问题 I have a basic Monostate with Python 2.6. class Borg(object): __shared_state = {} def __new__(cls, *args, **kwargs): self = object.__new__(cls, *args, **kwargs) self.__dict__ = cls.__shared_state return self def __init__(self, *args, **kwargs): noSend = kwargs.get("noSend", False) reportLevel = kwargs.get("reportLevel", 30) reportMethods = kwargs.get("reportMethods", "BaseReport") contacts= kwargs.get("contacts", None) a = Borg(contacts="Foo", noSend="Bar", ) Which happily gives me the