def def_getter(cls, attr_name: str):
    """
    Define a getter property of a given class.

    e.g.
    In below code, code 1 is same as code 2.

    # Code 1
    def_getter(C, '_foo')

    # Code 2
    class C:
        @property
        def foo(self):
            return self._foo

    """
    prop_name = attr_name.lstrip("_")

    def getter(self):
        return getattr(self, attr_name)

    setattr(cls, prop_name, property(getter))