Keep it simple.
If you have functions like that, just use a publicly accessible variable. That is:
class Person(object):
def __init__(self):
self.firstName = None
self.lastName = None
self.age = None
is perfectly fine. A better approach given the usage is to require the data as part of the constructor, thus:
class Person(object):
def __init__(self, firstName, lastName, age):
self.firstName = firstName
self.lastName = lastName
self.age = None
person = Person('Peter', 'Smith', 21)
If you are concerned about which name is which, you can always be specific:
person = Person(firstName='Peter', lastName='Smith', age=21)
In the future, if you need to make it more complex, you can add getters/setters where needed.
Another consideration is that given the constructor, you can create a string conversion function on the Person
object:
def __str__(self):
return ' '.join([self.firstName, self.lastName])
This then allows you to use it like:
person = Person(firstName='Peter', lastName='Smith', age=21)
print(person)
so you don't need to know how it is implemented internally.
Another consideration is that Chinese/Japanese names place the surname first, people can have multiple last names (esp. in Spain) and can have middle names.