Skip to content

Instantly share code, notes, and snippets.

@ndnichols
ndnichols / codegen.py
Created November 10, 2011 23:13 — forked from mattbasta/codegen.py
A module to "unparse" a Python AST tree.
# -*- coding: utf-8 -*-
"""
codegen
~~~~~~~
Extension to ast that allow ast -> python code generation.
:copyright: Copyright 2008 by Armin Ronacher.
:license: BSD.
"""
@ndnichols
ndnichols / buildProperties.coffee
Created November 15, 2012 17:28
A function for automatically adding getter/setters to Backbone models.
buildProperties = (func) ->
buildGetter = (name) ->
-> @get name
buildSetter = (name) ->
(value) -> @set name, value
for attr in func.prototype.attributeNames
Object.defineProperty func.prototype, attr,
get: buildGetter attr
set: buildSetter attr