Guest User

Untitled

a guest
Mar 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. def encode_pair(f):
  2. # Decorator function to encode "pair" to bytes object
  3. def new_f(*args, **kwargs):
  4. args = list(args)
  5. pair = args[1]
  6. if type(pair) == str:
  7. args[1] = pair.encode()
  8. assert type(args[1]) == bytes
  9. args = tuple(args)
  10. return f(*args, **kwargs)
  11. return new_f
Add Comment
Please, Sign In to add comment