May-24-2023, 07:47 PM
This cannot be in the main program:
This kind of thing is normally a bad idea.
It would be better to do this:
a = A(self) print(b)self should only be used to refer to the instance variable passed as the first argument in an instance method. self should never bee seen as a variable in your main program.
This kind of thing is normally a bad idea.
Class A: def __init__(self, parentobject): parentobject.b = b()But that doesn't mean it is always a bad idea.
It would be better to do this:
class A: def __init__(self, b): parentobject.b = b parentobject = ParentClass() a = A(parentobject.b())Instead of posting hypotheticals, why not post your real question?