# Abstract variables in abc

**URL:** <https://discuss.python.org/t/abstract-variables-in-abc/69071>\
**Category:** Python Help\
**Created:** [October 24, 2024, 2:43pm UTC](https://discuss.python.org/t/abstract-variables-in-abc/69071 "2024-10-24T14:43:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![drmason13](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/drmason13/32/22591_2.png) [@drmason13](https://discuss.python.org/u/drmason13)\
**Post date:** [October 24, 2024, 6:05pm UTC](https://discuss.python.org/t/abstract-variables-in-abc/69071/4 "2024-10-24T18:05:31Z")

</div>

More to the point you can define abstract _properties_:

```python
from abc import ABC, abstractmethod

class BaseClass(ABC):
    # Abstract property (must be defined in subclass)
    @property
    @abstractmethod
    def required_property(self):
        pass

    @classmethod
    def provided_method(cls):
        print(cls.required_property)

class SubClass(BaseClass):
    # Implementing the abstract property
    required_property = "I am from subclass"

# Usage
SubClass.provided_method() # I am from subclass

class BadSubClass(BaseClass):
    pass

BadSubClass() # TypeError: Can't instantiate abstract class

```

---

_[View the full topic](https://discuss.python.org/t/abstract-variables-in-abc/69071)._
