ich hab hier eine kleine Funktion, die die Datenattribute und Properties eines Objekts zurückgibt.
Code: Alles auswählen
import inspect
def get_attributes(obj, public_only=True):
attrs = inspect.getmembers(obj, lambda o: not inspect.isroutine(o))
if public_only:
return [x for x in attrs if x[0][0] != "_"]
else:
return attrs
Wird der Parameter public_only auf False gesetzt, werden auch private und Spezialattribute wie __dict__ zurückgeliefert.
Gruß
Dookie