tuple in redis / python: can store, not retrieve -


so, i've got redis working python -- exciting!

i need store tuple , retrieve / parse later. construct below isn't working, think because returned tuple quoted -- there quote on either end of it.

it seems me quotes indicate isn't tuple, rather string.

so know how redis return working tuple? thanks!

>>> tup1 = ('2011-04-05', 25.2390232323, 0.32093240923490, 25.239502352390) >>> r.lpush('9999', tup1) 1l >>> r.lpop('9999') "('2011-04-05', 25.2390232323, 0.3209324092349, 25.23950235239)" >>> v = r.lpop('9999') >>> test=v[0] traceback (most recent call last):   file "<stdin>", line 1, in <module> typeerror: 'nonetype' object has no attribute '__getitem__' 

you have popped , element v , element trying retrieve no longer exists.

try this:

>>> tup1 = ('2011-04-05', 25.2390232323, 0.32093240923490, 25.239502352390) >>> r.lpush('9999', tup1) >>> v = r.lpop('9999') >>> test = eval(v)[0] 

since return type string, need eval evaluate type


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -