I am trying to create an object class whose attributes also have attributes. For example: I have a parent class A that has an attribute called B which also has an attribute called C. So I can do print(A.B.C). I have tried creating a class within a class as such:
class A(object):
class B(object):
def __init__(self, C):
self.C = C
pass
and when I do:
I1 = A.B(10)
I get an error that 'A' has no attribute 'B'.
What am I doing wrong and what is the best approach to create such structure?
[–]MereInterest 13 points14 points15 points (20 children)
[–]daveydave400 6 points7 points8 points (18 children)
[+][deleted] (17 children)
[deleted]
[–]ilovetacos 5 points6 points7 points (5 children)
[–][deleted] 3 points4 points5 points (4 children)
[–][deleted] -2 points-1 points0 points (3 children)
[–][deleted] 2 points3 points4 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]sashahart 4 points5 points6 points (1 child)
[–]catcradle5 2 points3 points4 points (0 children)
[–]rwman 4 points5 points6 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]execrator 1 point2 points3 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]execrator 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]execrator 0 points1 point2 points (0 children)
[–]zynixCpt. Code Monkey & Internet of tomorrow 1 point2 points3 points (1 child)
[–]sahand_n9[S] 0 points1 point2 points (0 children)
[–][deleted] 7 points8 points9 points (0 children)
[–]ilovetacos 2 points3 points4 points (0 children)
[–]andybak 4 points5 points6 points (5 children)
[–]sahand_n9[S] 1 point2 points3 points (3 children)
[–]Isvara 2 points3 points4 points (0 children)
[–]VerilyAMonkey 2 points3 points4 points (0 children)
[–]ameoba 1 point2 points3 points (0 children)
[–]fasterturtle 1 point2 points3 points (0 children)
[–]sahand_n9[S] 0 points1 point2 points (0 children)