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