#!/usr/bin/env python3
def main():
from classes import Book
from classes import Textbook
b = Book('The Hitchhikers Guide to the Galaxy', 'Douglas Adams')
print(b.__str__())
b = Textbook('Cisco CCNP', 'Todd Lammle', '5')
print(b.__str__())
if __name__ == '__main__':
main()
classes.py
#!/usr/bin/env/python3
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
def __str__(self):
return 'Book: {} by {}'.format(self.title, self.author)
class Textbook(Book):
def __init__(self, title, author, edition) -> object:
super().__init__(title, author)
self.edition = edition
def __str__(self):
return 'Textbook: {} by {} edition {}'.format(self.title, self.author, self.edition)
Output
Book: The Hitchhikers Guide to the Galaxy by Douglas Adams
Textbook: Cisco CCNP by Todd Lammle edition 5