class Person(object):
def __init__(self,firstName,lastName):
self.firstName = firstName
self.lastName = lastName
def show(P):
print(P.firstName,P.lastName)
def stringToObject(string):
string = string.split()
fName = string[0]
lName = string[1]
return Person(fName,lName)
Also how would I access this object? I know if for example I created an object using: Example = Person("John","Smith"), I could access this using John.show() but I have no idea how to access the objects that the function creates, or if the code is even working, or if its the right way to go about it. Any help much appreciated as always.
Thanks in advance!

New Topic/Question
Reply



MultiQuote





|