[Solved] python self is acting up

Normally, when you create an instance of a class draw, the initialization routine draw.__init__ is automatically called for you, and the self argument is added implicitly, so you don’t specify it explicitly. Here’s the normal case: d = draw( canvas, 20, 40, … ) …and indeed that’s just what you seem to have assumed. Your … Read more

[Solved] Why the method in some class I created, ask me for input “self”? [closed]

You have to create an object of your class: class MyClass: def __init__(self,a=1,b=2): self.a=a self.b=b def function1(self): self.c=self.a/self.b + 5 return(self.c) print(MyClass().function1()) MyClass() creates an object that can be used to access attributes in the class. For a general instance: m = MyClass() print(m.function1()) 6 solved Why the method in some class I created, ask … Read more

[Solved] Class constructor able to init with an instance of the same class object

Not sure what you’re trying to achieve, but technically your error is here: self = kwargs.get(‘object’,self) There’s nothing magic with self, it’s just a function argument, and as such a local variable, so rebinding it within the function will only make the local name self points to another object within the function’s scope. It’s in … Read more