Custom Python Lists: Inheriting From list vs UserList

At some point in your Python coding adventure, you may need to create custom list-like classes with modified behavior, new functionalities, or both. To do this in Python, you can inherit from an abstract base class, subclass the built-in list class directly, or inherit from UserList, which lives in the collections module.

In this tutorial, you’ll learn how to:

  • Create custom list-like classes by inheriting from the built-in list class
  • Build custom list-like classes by subclassing UserList from the collections module

You’ll also write some examples that’ll help you decide which parent class, list or UserList, to use when creating your custom list classes.

To get the most out of this tutorial, you should be familiar with Python’s

 

 

 

To finish reading, please visit source site