Created
May 13, 2012 18:56
-
-
Save laserson/2689744 to your computer and use it in GitHub Desktop.
Generate Redis protocol with python
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: | |
proto += '$' + str(len(arg)) + '\r\n' | |
proto += str(arg) + '\r\n' | |
return proto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In python3 this will result in an incorrect length for unicode strings. Changing line 5 to
worked for me.