brian wickman - @wickman
[TOC]
Pants makes the manipulation and distribution of hermetically sealed Python environments
INSTALL_ROOT=$HOME/Python | |
CPY=$INSTALL_ROOT/CPython | |
PYPY=$INSTALL_ROOT/PyPy | |
SANDBOX=$(mktemp -d /tmp/python.XXXXXX) | |
CURL='wget --no-check-certificate' | |
mkdir -p $INSTALL_ROOT |
from abc import ABCMeta, abstractmethod | |
import threading | |
class ClockInterface(object): | |
__metaclass__ = ABCMeta | |
@abstractmethod | |
def time(self): | |
pass |
from abc import ABCMeta, abstractmethod | |
def documented_by(documenting_abc): | |
def document(cls): | |
cls_dict = cls.__dict__.copy() | |
for attr in documenting_abc.__abstractmethods__: | |
cls_dict[attr].__doc__ = getattr(documenting_abc, attr).__doc__ | |
return type(cls.__name__, cls.__mro__[1:], cls_dict) | |
return document |
Most of the commons python environment has been developed against CPython 2.6. Things mostly work with CPython 2.7 and recent efforts have been made to improve CPython 3.x and PyPy compatibility. We've explicitly ignored anything prior to CPython 2.6 and in fact generally discourage use against anything less than CPython 2.6.5 as there are known bugs that we're unwilling to fix. We've never even tried running against Jython or
import bottle | |
bottle.debug(True) | |
class BottleServer(object): | |
def __init__(self): | |
self.app = bottle.Bottle() | |
self.setup_routes() | |
def hello(self, **kw): |
class BottleServer(object): | |
@staticmethod | |
def route(*args, **kwargs): | |
def annotated(function): | |
if hasattr(function, '__routes__'): | |
function.__routes__.append( (args, kwargs) ) | |
else: | |
function.__routes__ = [(args, kwargs)] | |
return function | |
return annotated |
# E.g. TaskClass = CaseClass('name', 'owner', 'pid') | |
# task1 = TaskClass(name = "hello", owner = "brian", pid = 15) | |
# task2 = TaskClass(name = "world", owner = "brian", pid = 13) | |
# tasks = [task1, task2] | |
# | |
# filter(lambda task: task.where(owner = "brian"), tasks) => [task1, task2] | |
# filter(lambda task: task.where(owner = "brian", pid = 13), tasks) => [task2] | |
# | |
# matcher = TaskClass(pid = 13) | |
# filter(lambda task: task.match(matcher), tasks) => [task2] |