A
A
Artur Zenkov2016-03-29 20:58:38
Python
Artur Zenkov, 2016-03-29 20:58:38

What is an attribute in Python?

The dir(object) method lists the object's attributes. And the list has object methods. Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iegor, 2016-03-29
@Hrom

Attributes are all properties of an object, in fact - all variables defined inside the object and its parents. They are all entered into the object's dictionary and returned by the dir.
Want without methods -

list(filter(lambda attr: not callable(getattr(obj, attr)), dir(obj)))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question