""" Exercise 9.1 from "A primer on..." Demonstrate the magic of inheritance by creating an apparently empty subclass and checking its content using the dir function and the __dict__ attribute. """ import numpy as np class Line: def __init__(self, c0, c1): self.c0, self.c1 = c0, c1 def __call__(self, x): return self.c0 + self.c1*x def table(self, L, R, n): """Returner en tabell med n punkter for L <= x <= R.""" s = '' for x in np.linspace(L, R, n): y = self(x) s += f'{x:12g} {y:12g}\n' return s class Parabola0(Line): pass p = Parabola0(1,1) print(dir(p)) print(p.__dict__)