I have a python class (P) with a property x, which I use to store a single value in code that instantiates instances of P. Then, in a sub-class of class P (Q) I override (correct nomenclature?) x to instead store a list of values. This feels like just a case of making use of Python's dynamic typing. But is this Pythonic?
class P:
def __init__(self,x):
self.x = x
class Q(P):
def __init__(self,x):
self.x = [x]
>>> p = P(1)
>>> p.x
1
>>> q = Q(1)
>>> q.x
[1]
>>>