oop - Abstract attributes in Python -
what shortest / elegant way implement following scala code abstract attribute in python?
abstract class controller { val path: string }
a subclass of controller
enforced define "path" scala compiler. subclass this:
class mycontroller extends controller { override val path = "/home" }
python has built-in exception this, though won't encounter exception until runtime.
class base(object): @property def path(self): raise notimplementederror class subclass(base): path = 'blah'
Comments
Post a Comment