Last active
          May 28, 2020 03:25 
        
      - 
      
 - 
        
Save ducva/275be28640de409ad1eb4775accb0e3c to your computer and use it in GitHub Desktop.  
  
    
      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
    
  
  
    
  | def filter_message(prefix: str): | |
| def inner_check(func: typing.Callable[[str], None]): | |
| def inner_deeper_check(arg: str): | |
| if arg.startswith(prefix): | |
| print('Checking prefix....OK') | |
| func(arg) | |
| print('post process...OK') | |
| else: | |
| print('Checking prefix....Failed') | |
| print('access denied') | |
| return inner_deeper_check | |
| return inner_check | |
| @filter_message(prefix="test") | |
| def orig_func(arg1: str): | |
| print(f"arg1: {arg1}") | |
| if __name__ == "__main__": | |
| orig_func("Hello World!") | |
| orig_func("test: Hello World!") | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment