I'm quite new to programming and still learning my ropes. Apologies if this question is too elementary.
I feel it somewhat difficult to clarify my question, so here's an example of what I want to accomplish: Suppose that a is an instance of class X, and is supposed to have attributes a1, a2, a3, b1, b2, b3, c1, c2 and c3. I want to put a1 through a3, b1 through b3 and c1 through c3 into their own classes A, B, C nested under X for ease of use. What would be the correct syntax to do so?
class X:
def __init__ (self, name, A, B, C):
self.name = name
self.A = A
self.B = B
self.C = C
class A (X):
def _init_ (self, name, a1, a2, a3):
self.name = name
self.a1 = a1
self.a2 = a2
self.a3 = a3
class B (x):
def _init_ (self, name, b1, b2, b3):
self.name = name
self.b1 = a1
self.b2 = a2
self.b3 = a3
class C (X):
def _init_ (self, name, c1, c2, c3):
self.name = name
self.c1 = a1
self.c2 = a2
self.c3 = a3
Since This was built entirely on guesswork, I'm 99.9% certain it's wrong, but I am not sure what I should do next to make it right. I have tried searching for "nested classes" answers, but the answers I have found didn't really clarify my position.
Please explain proper Syntax for nested classes in Python.
Thanks for your help, and my apologies for this elementary question.
EDIT: There were some crucial typos in my codes that I have corrected just now. My apologies for any inconvenience.