Skip to content
Discussion options

You must be logged in to vote

The problem here is your Dog.__new__ implementation. It is supposed to return a new instance of the class, but you are returning the class object itself:

>>> type(Dog())
type # should be "Dog"

So your dog is not an instance of Dog (but of type), that's why the instance syntax is not working. I believe the class method syntax works here, because it does not validate what self is. It could be any unrelated type for that matter:

class A:
    ...

class Dog:
    def configure(self, valid_config):
        self.cfg = valid_config

>>> a = A()
>>> Dog.configure(a, {})
>>> a.cfg
{}

This pure Python example works without problem (but pretty cursed I guess)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ds1sqe
Comment options

@ds1sqe
Comment options

Answer selected by ds1sqe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants