class Fabric: def __init__(self, humans): self.Body = humans def set_eyes(self, value) self.Body.top.eyes = value print(self.Body.top.eyes)then
fabric.set_eyes(4)
. you need to use
self
, not fabric
. self
is the instance, which is passed automatically. But this is anti-pattern in python. Normally we don't need need setters and getters just to modify a property. We will do fabric.Body.top.eyes = 4
outside the class, without the need to define Fabric.set_eyes()
method.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs