Python Shelve could not retrieve object
<p>I tried to store objects and was able to do it successfully..But I have problems, while treiving it..Error is given below</p>

<p>person.py</p>

<pre><code>class Person:
    def __init__(self, name, age, pay=0, job=None):
        self.name = name
        self.age  = age
        self.pay  = pay
        self.job  = job

    def lastname(self):
        return  self.name.split()[-1]

    def giveraise(self,percent):
        #return self.pay *= (1.0 + percent)
        self.pay *= (1.0 + percent)
        return self.pay
</code></pre>

<p>Manager.py</p>

<pre><code>from Person import Person

class Manager(Person):
    def giveRaise(self, percent, bonus=0.1):
        self.pay *= (1.0 + percent + bonus)        
        return self.pay
</code></pre>

<p>update_db_classes.py</p>

<pre><code>import shelve
from Person import Person
from Manager import Manager
bob = Person('Bob Smith', 42, 30000, 'software')
sue = Person('Sue Jones', 45, 40000, 'hardware')
tom = Manager('Tom Doe',  50, 50000)

db = shelve.open('class-shelve')
db['bob'] = bob
db['sue'] = sue
db['tom'] = tom
db.close()
</code></pre>

<p>Code to retrieve the objects..
dump_db_classes.py</p>

<pre><code>import shelve
db = shelve.open('class-shelve')
for key in db:
    print(key, '=&gt;\n  ', db[key].name, db[key].pay)

bob = db['bob']
print(bob.lastName())
print(db['tom'].lastName())
</code></pre>

<p>Error:
C:\Python27\Basics>dump_db_classes.py
bob =>
   Bob Smith 30000
sue =>
   Sue Jones 40000
tom =>
   Tom Doe 50000

Traceback (most recent call last):
  File "C:\Python27\Basics\dump_db_classes.py", line 8, in 
    print(bob.lastName())
AttributeError: 'Person' object has no attribute 'lastName'</p>
