I was reading "Dive Into Python" and in the chapter on classes it gives this example:
class FileInfo(UserDict): "store file metadata" def __init__(self, filename=None): UserDict.__init__(self) self["name"] = filename
The author then says that if you want to override the
__init__ method, you must explicitly call the parent
__init__ with the correct parameters.
FileInfoclass had more than one ancestor class?
The book is a bit dated with respect to subclass-superclass calling. It"s also a little dated with respect to subclassing built-in classes.
It looks like this nowadays:
class FileInfo(dict): """store file metadata""" def __init__(self, filename=None): super(FileInfo, self).__init__() self["name"] = filename
Note the following:
We can directly subclass built-in classes, like
super function handles tracking down this class"s superclasses and calling functions in them appropriately.
A Problem-Solver’s Guide to Building Real-World Intelligent Systems. Data is the new oil and Machine Learning is a powerful concept and framework for making the best out of it. In this age of aut...
The ability to identify patterns is an essential component of sensory intelli- gent machines. Pattern recognition is therefore an indispensible component of the so-called “Intelligent Control System...
Topics on Big Data are growing rapidly. From the first 3 V’s that originally characterized Big Data, the industry now has identified 42 V’s associated with Big Data. The list of how we characteriz...
Introduction to Machine Learning with Python: A Guide for Data Scientists 1st Edition. Machine learning has become an integral part of many commercial applications and research projects, but this f...