enough to do the trickpython typesubclass py [' '' '' '[' '' '' '(indexing [' '' '' 'at (indexing [' '' '' 'at [' '' '' ''spam'['spam'' '' '' 'this output also includes tracing text the class prints on indexing of coursewhether changing indexing this way is good idea in general is another issue--users of your mylist class may very well be confused by such core departure from python sequence behaviorthe ability to customize built-in types this way can be powerful assetthough for instancethis coding pattern gives rise to an alternative way to code set--as subclass of the built-in list typerather than standalone class that manages an embedded list object as shown in the prior section as we learned in python today comes with powerful built-in set objectalong with literal and comprehension syntax for making new sets coding one yourselfthoughis still great way to learn about type subclassing in general the following classcoded in the file setsubclass pycustomizes lists to add just methods and operators related to set processing because all other behavior is inherited from the built-in list superclassthis makes for shorter and simpler alternative--everything not defined here is routed to list directlyfrom __future__ import print_function compatibility class set(list)def __init__(selfvalue [])list __init__([]self concat(valueconstructor customizes list copies mutable defaults def intersect(selfother)res [for in selfif in otherres append(xreturn set(resother is any sequence self is the subject def union(selfother)res set(selfres concat(otherreturn res other is any sequence copy me and my list def concat(selfvalue)for in valueif not in selfvaluelistsetetc removes duplicates advanced class topics pick common items return new set