Embedded in a string, a la Pymeta
parser = Parser("""
integer ::= \d+
atom ::= integer | s_expression
atoms ::= (atom,?\s*)*
s_expression ::= "(" atoms ")"
""")
$ sixteen-debug examples/quick_example.bin | |
SET A 0x0030 | |
>> registers | |
A: 0030 C: 0000 B: 0000 I: 0000 J: 0000 O: 0000 PC: 0002 SP: ffff Y: 0000 X: 0000 Z: 0000 | |
>>>> | |
SET [0x1000] 0x0020 | |
>> | |
SUB A [0x1000] | |
>> | |
IFN A 0x0010 |
#!/usr/bin/env python | |
from wsgiref.handlers import CGIHandler | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/') | |
def hello_world(): | |
return 'Hello World!' |
# This is the API everything inherits from | |
class GenericApplicationConfigurationClass(object): | |
def __init__(self): | |
self.looper = Looper() | |
# And the small, configuration-only script I intend to write for each specific case |
class MyClass(object): | |
def __init__(self, c): | |
c.width = self.calculate_width() | |
c.height = self.calculate_height() | |
def calculate_width(self): | |
return 10 | |
def calculate_height(self): | |
return 20 |
class Looper(object): | |
def __init__(self, function): | |
function(self) | |
@Looper | |
def my_looper(self): | |
self.height = 130 | |
self.width = 120 |
products = { | |
"sam": "Subscription Asset Manager - Subscription Management", | |
"headpin": "Headpin - Open Source Subscription Management", | |
"katello", "Katello - Open Source Systems Management" | |
} | |
class Page(object): | |
"Base class for all Pages" | |
def __init__(self, testsetup): | |
"Initializer." |
Embedded in a string, a la Pymeta
parser = Parser("""
integer ::= \d+
atom ::= integer | s_expression
atoms ::= (atom,?\s*)*
s_expression ::= "(" atoms ")"
""")
class FalseClass(type): | |
def __int__(self): | |
return 13 | |
class C(object): | |
__metaclass__ = FalseClass | |
print int(C) |
from functools import wraps | |
def curried(fn, args=None): | |
args = args or () | |
@wraps(fn) | |
def curried_wrapper(*new_args): | |
if len(args + new_args) < fn.func_code.co_argcount: | |
return curried(fn, args + new_args) | |
else: |
require 'formula' | |
# Homebrew formula for das. | |
# das: http://github.com/jonpovey/das | |
# install with: | |
# `brew install https://gist.github.com/raw/2664491/das.rb` | |
# or save this file somewhere and "brew install das.rb" | |
class Das < Formula |