I am learning python and encountered a problem that I don't understand. I have created a class called Person in a file classes_parent.py
class Person:
def __init__(self, fname, lname):
self.firstname = fname
self.lastname = lname
def printname(self):
print(self.firstname, self.lastname)
x = Person('John', 'Doe')
x.printname()
I have created a subclass called Student in file classes_child.py:
from classes_parent import Person
class Student(Person):
pass
s = Student('Alex', 'Doe')
s.printname()
The problem is that the output when I run classes_child.py is this:
John Doe
Alex Doe
Why I get both names and not just the student name, i.e. Alex Doe?