[Python] Determine if a function/method has an implementation that isn't "pass"

Discussão em 'Python' iniciado por Stack, Abril 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have a class that declares a property in Python, the default implementation for this method is pass, for example:

    class A:

    @property
    def something(self):
    pass


    This property is intended to declare a functionality for extending classes, and I want to use it to declare a field, where if extending classes implemented it, the field is initialized to some value, and if they don't then the value of the field is None.

    How can I check if users did implement it?

    I tried using __code__ and hasattr() but that didn't work.

    Continue reading...

Compartilhe esta Página