title: why I get "AttributeError: class <class name> has no attribute <attribute name>" even I've clearly defined the attribute
body: <p>I just started programming an assembler for a project, however, I am getting the following error while I am trying to run it. It says that some attribute is not defined even though I have defined it. I don't understand what is happening.</p>
  <pre><code>Traceback (most recent call last):
    File &quot;./Assembler.py&quot;, line 27, in &lt;module&gt;
      main()
    File &quot;./Assembler.py&quot;, line 22, in main
      P = Parser.inst
  AttributeError: class Parser has no attribute 'inst'
  </code></pre>
  <p>This is the code.</p>
  <pre class="lang-py prettyprint-override"><code>class Parser:
      def __init__(self, inst, type):
          self.inst = inst.strip()
          self.type = None
          self.checkType()
  
      def checkType(self):
          if self.inst.startswith('//') or self.inst in ['\n', '\r\n']:
              return
  
          elif self.inst.startswith('@'):
              self.type = 'A'
  
          else:
              self.type = 'C'
  
  def main():
      with open(sys.argv[1], 'r') as asm:
          for inst in asm:
                  P = Parser.inst
                  print(p.type)
  
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>