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
def gen_redis_proto(*args): | |
proto = '' | |
proto += '*' + str(len(args)) + '\r\n' | |
for arg in args: | |
# Pick one of the two below lines and comment out the other. | |
# Python 2 | |
proto += '$' + str(len(arg)) + '\r\n' | |
# Due to python 3's string changes len no longer returns the number of bytes | |
# in a string and instead returns the number of characters. The redis protocol | |
# needs the number of bytes. In order to get the bytes we coerce it into a byte |