May-24-2023, 02:51 PM
(This post was last modified: May-24-2023, 02:51 PM by deanhystad.)
Your examples are more baffling than illustrative. Is somemethod() supposed to be a method of Aclass? In your example it is a function, not a method of Aclass. An example should be valid Python code.
class Bclass: pass class Aclass: def somemethod(self): self.B = Bclass obj_a = Aclass() obj_a.B # Will raise an AttributeError because B does not exist yet. obj_a.somemethod() # This creates B obj_a,B # Returns Bclass.The answer is that an object attribute is an object attribute. The type of the attribute does not matter.