title: why does it say that my class doesn't have the attribute?
body: <p>here's my code:</p>
  
  <pre><code>class Regex:
      def __init__(self: 'Regex',
                      value: object =None, child: list =None, child2: list = None):  
          """node with value and any nummber of children"""
          list_of_regex = [0,1,2,'e','|','.','*']
          self.value = value
          if self.value not in list_of_regex:
                  raise Exception
          if not child:
              self.child = []
          if not child2:
              self.child2 = []
          else:
              self.child = child[:]
              self.child = child2[:]
  
      def __repr__(self: 'Regex') -&gt; str:
          return ('Regex(' + repr(self.value) + ', ' +
                          repr(self.child) + ', ' + repr(self.child2) + ')') 
  </code></pre>
  
  <p>when i input the following in my python shell:</p>
  
  <pre><code>&gt;&gt;&gt;Regex(1,[1])
  </code></pre>
  
  <p>the output is:</p>
  
  <pre><code>    Traceback (most recent call last):
    File "C:\Program Files (x86)\Wing IDE 101 5.0\src\debug\tserver\_sandbox.py", line 1,     in &lt;module&gt;
      # Used internally for debug sandbox under external interpreter
    File "C:\Program Files (x86)\Wing IDE 101 5.0\src\debug\tserver\_sandbox.py", line 19,      in __repr__
  builtins.AttributeError: 'Regex' object has no attribute 'child'
  </code></pre>
  
  <p>I'm not sure why it tells me that my class doesn't have the attribute 'child'. Look what happens when i try these two different calls.</p>
  
  <pre><code>&gt;&gt;&gt;c = Regex(1)
  &gt;&gt;&gt;c.child
  []
  
  &gt;&gt;&gt;c = Regex(1,[1])
  &gt;&gt;&gt;c.child
  Traceback (most recent call last):
  File "&lt;string&gt;", line 1, in &lt;fragment&gt;
  builtins.AttributeError: 'Regex' object has no attribute 'child'
  </code></pre>
  
  <p>what's wrong with the code?</p>