Hi I am new to python. So i am having problem while coding.
Here the code
import sys
class Person:
def __init__(self):
self.list = []
def AddContact(self):
fname = raw_input("First Name:> ")
lname = raw_input("Last Name:> ")
street = raw_input("Street:> ")
self.list = [ fname, lname, street]
def ListAll(self):
print ""
def DeleteContact():
print ""
class NewPerson():
v = Person()
def __init__(self):
def option(self):
print "--------- Options ---------\n"
print " |1) Add/Update |\n"
print " |2) List All |\n"
print " |3) Delete Contact |\n"
print " |4) Exit |\n"
opt = raw_input(":> ").lower()
if opt == '1':
v.AddContact()
elif opt == '2':
v.ListAll()
elif opt =='3':
v.DeleteContact()
elif opt == '4':
sys.exit
else:
print "Invalid choice."
self.option()
if __name__ == '__main__':
v = NewPerson()
v.option()
I am getting error
Traceback (most recent call last):
File "C:\Python25\classAddress1.py", line 56, in <module>
v.option()
File "C:\Python25\classAddress1.py", line 43, in option
v.AddContact()
AttributeError: NewPerson instance has no attribute 'AddContact'
Help me out....So i wanted to know how to call some class method in another class.
Thanks