Skip to content

Instantly share code, notes, and snippets.

@uberscientist
Created March 9, 2018 20:47
Show Gist options
  • Save uberscientist/e8182e5a71450da044246b302959e891 to your computer and use it in GitHub Desktop.
Save uberscientist/e8182e5a71450da044246b302959e891 to your computer and use it in GitHub Desktop.
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
@Penguin2600
Copy link

🇵🇱

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment