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 following Deprecation warning..
untitled:4: DeprecationWarning: object.__new__() takes no parameters
self = object.__new__(cls, *args, **kwargs)
After a bit of googling I find this is attached to Bug #1683368. What I can't figure out is what this means. It's complaining about the following line
self = object.__new__(cls, *args, **kwargs)
Which appears to be OK. Can someone explain in laymens terms why this is a problem. I understand that "this is inconsistent with other built-ins, like list" but I'm not sure I understand why. Would someone explain this show me the right way to do it?
Thanks