Skip to content

Instantly share code, notes, and snippets.

@tenuki
tenuki / gist:f5eb5ea3274c58db3395
Last active August 29, 2015 14:03
Name a lambda
# A very simple recipe to allow you easily name lambda-objects
#(or other kind of objects, callable, for example, partial
#objects) you create, with little overhead and friendly syntax.
def Name(**kw):
assert len(kw)==1
name, obj = kw.items()[0]
obj.func_name = name
return obj
@tenuki
tenuki / macro_module.py
Created February 20, 2014 17:03
python use decimal as default type for non-integer numbers using macropy
# macro_module.py
from macropy.core.macros import *
from macropy.core.walkers import Walker
macros = Macros()
@macros.expr
def expand(tree, **kw):
return to_decimal(tree)
@macros.expr