Created
August 22, 2012 17:47
-
-
Save sbehrens/3427871 to your computer and use it in GitHub Desktop.
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 decode_string(x, f): | |
colon = x.index(':', f) | |
try: | |
n = int(x[f:colon]) | |
except (OverflowError, ValueError): | |
n = long(x[f:colon]) | |
if x[f] == '0' and colon != f+1: | |
raise ValueError | |
colon += 1 | |
return (x[colon:colon+n], colon+n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment