Converting a deque object into list

Julius F picture Julius F · Apr 24, 2011 · Viewed 31.9k times · Source

currently I fetch "list" data from my storage, "deque" it to work with that data. After processing the fetched data I have to put them back into the storage. This won't be a problem as long as I am not forced (at least I think so) to use python's standard "list" object to save this data.

Storage Service: Google Appengine.

My work-around would be:

dequeObj = deque(myData)
my_list= list()
for obj in dequeObj:
    my_list.append(obj)

but this seems not very optimal.

Answer

Ignacio Vazquez-Abrams picture Ignacio Vazquez-Abrams · Apr 24, 2011
>>> list(collections.deque((1, 2, 3)))
[1, 2, 3]