I would like to have an abstract class in which I will have an abstract 
property. So I used Pycharm in order to create an abstract (base) class:

import abc


class BaseSomeAbstract(abc.ABC):
    _abs_prop = None

    @property
    @abc.abstractmethod
    def abs_prop(self):
        return self._abs_prop

    @abs_prop.setter
    @abc.abstractmethod
    def abs_prop(self, value):
        self._abs_prop = value

Now I have created a new file and a new class:

from subclassing.abstract.BaseSomeAbstract import BaseSomeAbstract


class ChildSomeAbstract(BaseSomeAbstract):



Now I pressed alt+enter, implement abstract methods. I got only a single choice 
abs_prop(self: BaseSomeAbstract).
If I choose this option, my subclass looks like this:

from subclassing.abstract.BaseSomeAbstract import BaseSomeAbstract


class ChildSomeAbstract(BaseSomeAbstract):

    @property
    def abs_prop(self):
        pass

Why Pycharm didn't offer a setter as well as getter?


What is the propper way to define an abstract property, and how to force 
subclass to define setter and getter for the abstract property?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to