This file contains hidden or 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
    
  
  
    
  | from functools import wraps | |
| def trace(func): | |
| @wraps | |
| def wrapper(*args, **kwargs): | |
| result = func(*args, **kwargs) | |
| print('%s(%r, %r) -> %r' % | |
| (func.__name__, args, kwargs, result)) | |
| return result | 
  
    
      This file contains hidden or 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
    
  
  
    
  | # Python 3 | |
| def to_str(bytes_or_str): | |
| if isinstance(bytes_or_str, bytes): | |
| value = bytes_or_str.decode('utf-8') | |
| else: | |
| value = bytes_or_str | |
| return value # Instance of str | |
| def to_bytes(bytes_or_str): | 
NewerOlder