【发布时间】:2019-12-12 20:35:04
【问题描述】:
我已经实现了一个抽象类:
from abc import ABC, abstractmethod
class Study(ABC):
""" Define the purpose of the study here """
def __init__(self, value):
self.value = value
@abstractmethod
def do_something(self):
pass
我还实现了一个子类:
class PilotStudy(Study):
def do_something(self):
print('Pilot Study')
我想强制子类在类定义下面定义一个文档字符串。有没有办法我可以做到这一点(这样我上面定义的子类会抛出错误,因为该类中没有文档字符串)?
【问题讨论】:
标签: python inheritance abstract-class