Suppose o
is a Python object, and I want all of the fields of o
, without any methods or __stuff__
. How can this be done?
I've tried things like:
[f for f in dir(o) if not callable(f)]
[f for f in dir(o) if not inspect.ismethod(f)]
but these return the same as dir(o)
, presumably because dir
gives a list of strings. Also, things like __class__
would be returned here, even if I get this to work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…