title: Python: object has no attribute
body: <p>I have two classes: MyClass and MyClass2. For MyClass I took a file and returned every word on that file. In MyClass2 I inherited MyClass and basically wrote a code that was supposed to store all the words in a dictionary along with a frequency of the words as the values.
  The first class I already tested and it was able to return every word. MyClass2 I thought I had written correctly, but I think I'm not inheriting MyClass right or my <strong>iter</strong> method is written incorreclty. Every time I try to run my code, it returns an error.
  <strong>Since this is a homework assignment, (Also I don't want to be thought of as cheating..) I won't post all my code unless it is necessary to answer my questions nor will I be expecting anyone to rewrite or completely fix my code.</strong> I just need some guidance on whether or not my constructor is wrong or if the entire code is wrong, or if I'm just not formatting my code correctly and inheriting the class wrong...? 
  I am new to python and I just need help.</p>
  
  <pre><code>from myclass import MyClass
  class MyClass2(MyClass):
        def __init__(self, Dict):    #Is the problem within the constructor?
            self.Dict = Dict
            Dict = {}
        def dict(self, textfile):
            text = MyClass(textfile)    #Was I wrong here??
            ..................
                ..............
                ..............
                return self.Dict
        def __iter__(self):
            for key, value in self.Dict.items():
                yield key, value
  </code></pre>
  
  <p>When I run a test code, I get an error that says :</p>
  
  <pre><code>AttributeError: 'MyClass2' object has no attribute 'items'
  </code></pre>
  
  <p>Please let me know if I am missing anythign or if there isn't enough information.</p>
  
  <p>I tested it using this code which was given: </p>
  
  <pre><code>filename = MyClass1('name of file')
  y = MyClass2(filename)
  for x in y:
      print x
  </code></pre>
  
  <p>Here is the traceback:</p>
  
  <pre><code>Traceback (most recent call last):
  File "C:\myclass.py", line 25, in &lt;module&gt;
    for x in y:
  File "C:\myclass2.py", line 19, in __iter__
    for key, value in self.Dict.items():
  AttributeError: 'MyClass2' object has no attribute 'items'
  </code></pre>