Use the
abc module to create abstract classes. Use the abstractmethod decorator to declare a method abstract, and declare a class abstract using one of three ways, depending upon your Python version.
In Python 3.4 and above, you can inherit from
ABC. In earlier versions of Python, you need to specify your class's metaclass as ABCMeta . Specifying the metaclass has different syntax in Python 3 and Python 2. The three possibilities are shown below:
|
Saturday 3 June 2017
Abstract in python
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment