Вопрос

Does anyone know how to get reversed bucket list.

bucketList = self.bucket.list(PREFIX)
bucketList.reverse()

does not work.

Thanks, Ron.

Это было полезно?

Решение

The reason that you can't do a reverse of bucket.list() is because that method actually returns a generator rather than the actual list. This is much more efficient and also allows boto to handle all of the paging of results behind the scenes.

If you really want to reverse it you could collect all of the elements in a list and then reverse that:

objs = [obj for obj in self.bucket.list(PREFIX)]
objs.reverse()

but if there are a lot of objects in the bucket this will be very inefficient.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top