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 api(arg): | |
| if isinstance(arg, (str, bytes)): | |
| if isinstance(arg, bytes): | |
| arg = arg.decode('utf8') | |
| arg = [arg] | |
| ... # do something | |
| return arg | |
| print(api(b'123')) # -> ['123'] |
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
| """ | |
| Using Pygame, provided requirements with Nix, make a smiley take | |
| a random walk around the display | |
| Put a smiley.png in the same folder, and execute with: | |
| python -m pygame_demo | |
| """ | |
| import pygame |
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
| >>> class Error(Exception): | |
| ... def __init__(self, foo, bar): | |
| ... return super().__init__(foo, bar) | |
| ... | |
| >>> Error('blah', 'blah') | |
| Error('blah', 'blah') | |
| >>> pickle.loads(pickle.dumps(Error('blah', 'blah'))) | |
| Error('blah', 'blah') | |
| Fails: |
OlderNewer