This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import takewhile, islice, cycle | |
# chunkify(xrange(1, 11), 2) => [[1,2], [3,4], [5,6], [7,8], [9,10]] | |
def chunkify(iterable, chunk_size): | |
_iterable = iter(iterable) | |
return takewhile(lambda x: x, | |
(list(islice(_iterable, chunk_size)) for _ in cycle([True]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import redis | |
>>> db = redis.Redis() | |
>>> db.flushall() | |
True | |
>>> db.set(u"фу".encode('utf-8'), u"бар".encode('utf-8')) | |
True | |
>>> db.keys('*') | |
['\xd1\x84\xd1\x83'] | |
>>> print db.keys('*')[0].decode('utf-8') | |
фу |
NewerOlder