M
M
Max Payne2019-03-30 23:06:28
Python
Max Payne, 2019-03-30 23:06:28

How to get property value in child class?

Let's say there is a class with the following property:

@property
@functools.lru_cache(maxsize=64)
def permission(self) -> int:
    return 1

we inherit this class, and it would be nice to get the permission value from the parent. How to do it? Something like this
@property
@functools.lru_cache(maxsize=64)
def permission(self) -> int:
    return Base.__init__(self, self.bot).permission + 1

It will not work because, most likely, the rewriting of some class properties that occurs during initialization.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2019-03-31
@deliro

Did they forget to tell you about super in the school of programmers?
5c9fdab65973c072029485.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question