Instantiating sub-class from super
On 14/10/2019 21:55, DL Neil via Python-list wrote:
> Is there a technique or pattern for taking a (partially-) populated
> instance of a class, and re-creating it as an instance of one of its
> In a medically-oriented situation, we have a Person() class, and start
> collecting information within an instance (person = Person(), etc).
> During the data-collection process the person's sex may become obvious,
> eg few males have become/been pregnant.
> We could stick with Person() and implement specific methods therein,
> rather than separate Man and Woman sub-classes, but...
> It seemed better (at the design-level) to have Man( Person ) and Woman(
> Person ) sub-classes to contain the pertinent attributes, source more
> detailed and specific questions, and collect such data; by gender.
Knowing a lot of Trans people as I do, may I gently suggest that this
solution will find many and varied ways of coming back to bite you?
Rhodri James *-* Kynesim Ltd