-2

I want to apply some statistics on a list of objects of a class. These objects have 6 values (open, high, low, close, volume and timestamp) each. Lets say i want to print a list with just the volume of each object. How can i do this?

  • I think this post might help you https://stackoverflow.com/questions/739882/iterating-over-object-instances-of-a-given-class-in-python – Alan Apr 22 '18 at 09:28

1 Answers1

0

Try adding this method to your class definition:

def returnVolume(self):
    return self.volume

In theory, this should return the volume of your objects when you call the function upon them.

Another way which would work would be to use list comprehensions (see the other answer).

Adi219
  • 4,712
  • 2
  • 20
  • 43