oop - Tell base class function to do different things dependent on the calling subclass -
in base class, have following code:
@staticmethod def _split_on_empty_lines(file_contents): """generator yields sections of file separated empty lines""" section = '' line in file_contents: if line.strip(): section += line else: _section_yield_function() section = ''
the _section_yield_function()
supposed different things in 2 subclasses. in first one, should check whether line after empty line empty before yielding it; in other one, should not perform check.
i read calling class of function not known inside function context, way implement kind of behaviour?
Comments
Post a Comment