Skip to content

Instantly share code, notes, and snippets.

View aaronchall's full-sized avatar
😗
Working!

Aaron Hall aaronchall

😗
Working!
View GitHub Profile
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']
"""
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
@aaronchall
aaronchall / pickledemo
Last active November 6, 2021 16:57
pickle demo
>>> 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: