Editor

Build a TimestampMixin

Advanced · Write the code · from Python Multiple Inheritance and MRO: How It Actually Works

From the lesson: Python Multiple Inheritance and MRO: How It Actually Works

Think about how you inherit traits from your parents. You might have your mom's eyes and your dad's sense of humor. You didn't pick one parent - you got traits from both.

Read the lesson

Create a TimestampMixin class with a method created_info() that returns the string 'Created by <class_name>' where <class_name> is the actual class name. Then create a Document class that inherits from TimestampMixin and has an __init__ that takes a title. Print the title and the created_info().

Expected output:

My Report
Created by Document
# Create TimestampMixin and Document

More Multiple Inheritance exercises

All Python exercises · 50 practice problems · Object-Oriented Programming quiz