Python Forum

Full Version: How I can recognize that member is classmethod of staticmethod?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to get only MY variables of the class and for this I wrote such a function:

import inspect
class MyClass:
...
...
    @classmethod
    def get_object_dict(cls):
        result = {}
        for key, value in cls.__dict__.items():
            if key.startswith('__') or callable(value): continue
            if inspect.ismethod(value): continue
            result[key] = value
            
        return result
...
...
In my dict 'result' I also get classmethod and staticmethod. How I can do my task?

I found this solution:
if type(value) == classmethod or type(value) == staticmethod: continue