0

The dir() function returns the list of all the returns, all properties and methods of a specific object, without any values.

How to return the values? I try to loop through the list, without success.

As an example, I tried to loop as such:

for attr in dir(results1):
    print(results1.attr)
Alexander Pivovarov
  • 4,850
  • 1
  • 11
  • 34

1 Answers1

4

Try this:

for attr in dir(results1):
    print(getattr(results1,attr))

You need to use getattr since attr is a string rather than a literal attribute name.

Tom Karzes
  • 22,815
  • 2
  • 22
  • 41