Created
March 9, 2018 20:47
-
-
Save uberscientist/e8182e5a71450da044246b302959e891 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 encode_pair(f): | |
# Decorator function to encode "pair" to bytes object | |
def new_f(*args, **kwargs): | |
args = list(args) | |
pair = args[1] | |
if type(pair) == str: | |
args[1] = pair.encode() | |
assert type(args[1]) == bytes | |
args = tuple(args) | |
return f(*args, **kwargs) | |
return new_f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🇵🇱