The UserList class in Python Tutorial

Similar to the UserDict and UserString classes, the UserList class too acts as a wrapper, but in this case for list objects. In other words it serves as a useful base class for all of your list-like classes to extend from. Therefore, you can inherit the methods of the list class, override them, or add fresh ones.

Also, like with UserDict and UserString, the UserList class needs has been diminished largely due to the fact that you can subclass the List class directly in recent versions of python. Also, like UserString and UserDict, the UserList class also offers an attribute known as data which stores the contents of the UserList class.

Below are the details for UserList in python:

class collections.UserList([list])

Below is an example of how to use the class:

>>> from collections import UserList
>>> players = UserList({'player_one': 'Too good', 'score': 500})
>>> players.data
['player_one', 'score']
============================================================================ Want to learn how to use Python's most popular IDE Pycharm? In the free pdf guide "Getting the Hang of PyCharm" you'll learn all of the amazing features in PyCharm along with how to get started with data science. Subscribe to the Purcell Consult newsletter and get started A.S.A.P.