Feb-17-2019, 07:01 AM
(This post was last modified: Feb-17-2019, 07:19 AM by AlekseyPython.)
I want to get only MY variables of the class and for this I wrote such a function:
I found this solution:
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
