Python > Classes: Basics
Hello, world!
class Person:
def __init__(self, fullname):
self.first, self.last = fullname.split()
def greet(self):
print('Hello, {}!'.format(self.first))
def print(self):
print('{0.last}, {0.first}'.format(self))
john = Person('John Smith')
john.greet()
john.print()
Hello, John!
Smith, John