Skip to content

Instantly share code, notes, and snippets.

env = {}
def lisp(sexpression):
if isinstance(sexpression, list):
if sexpression[0] == 'quote':
return sexpression[1:]
elif sexpression[0] == 'defn':
env[sexpression[1]] = lisp(sexpression[2])
# Hack for variable assignment.
>>> a = 1,
>>> assert (1,) == a
>>> a
(1,)
>>> l = []
>>> l.append(a)
>>> l
[(1,)]
>>> l.append(1,)
>>> l
from random import SystemRandom
random = SystemRandom()
INPUT_FILE = '6944719-tree-sunset-reflection.bmp'
OUTPUT_FILE = 'glitch.bmp'
with open(INPUT_FILE, 'rb') as rh:
with open(OUTPUT_FILE, 'wb') as wh:
"""
Super simple construction free roam RPG.
"""
from itertools import product
import os
import sys
from getch import getch
# Idea shamelessly stolen from pyramid.
# utils.py
from collections import Mapping
from functools import wraps
from flask import has_request_context, render_template
def render_dict_template(template):
def make_url(base, *fragments):
"""
>>> make_url('http://example.com', '1', '2', '3.html')
'http://example.com/1/2/3.html'
"""
path = str(pathlib.Path(*fragments))
return urllib.parse.urljoin(base, path)
from functools import partial
import sched
import time
class Scheduler:
"""
A wrapper around a scheduler class providing
a simple API for recurring events.
"""
"""
Simple module for microservices.
"""
import configparser
import json
import os
from routes import Mapper
import waitress
"""
Example state machine with conditions.
"""
from functools import partialmethod
" Possible states."
WORK = 'Work'
TRAVEL = 'Travel'
➜ ~ cat foo.py
x = tuple(set(["a", "b"]))
y = tuple(set(["b", "a"]))
print(x == y)
➜ ~ python3.5 foo.py
False
➜ ~ python3.5 foo.py
False
➜ ~ python3.5 foo.py
True