Q:

Abstract class that forces to hold object of type with constant name

I'm creating an abstract class that I want all its inheritance to hold an object of type X with the exact name.
See an example:
from abc import ABC, abstractmethod

class Hands(object):
    pass

class human(ABC):

    def __init__(self):

        self.hand=Hands()

        @property
        def Hands(self):
            pass

class american_hands(Hands):
    pass

#I want to make sure that a class of type human will have a member of type hands which is called hand
class american(human):

    def __init__(self):
        self.hand=american_hands()

How can I force the descendants of class human to hold a member of the desired type with a predefined name?
For example, i would like anyone who is implementing class human without a self.hand of type Hand, would raise an error, for example, this:
class German(Human):
    def __init__(self):
        super().__init__()

wouldn't work.

A:

Perhaps something like
class Hands:
    pass

class AmericanHands(Hands):
    pass

class Human:
    hand_type = Hands

    def __init__(self):
        self.hands = self.hand_type()

class American(Human):
    hand_type = AmericanHands

    def __init__(self):
        super().__init__()
        # Other American-specific initialization

h = Human()  # assert isinstance(h.hands, Hands)
a = American()  # assert isinstance(a.hands, AmericanHands)

The call to super().__init__ ensures that an instance of American has an attribute named hands, while the override class attribute ensures that the type of hands is correct.

