Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import collections
import sys
def tokens(f):
for line in f:
for t in line.split():
yield t
'''
Shorthand decorator for the common case of looking up ORM objects from
named URL parameters.
For each named URL parameter passed to the view of the form
``db_table_id``, look up the ORM object in the corresponding model with
the given primary key, returning a 404 in case it is not found.
For example:
(defn evens
([] nil)
([x] nil)
([x y & xs]
(lazy-seq (cons y (apply evens xs)))))
(defn factorial [n]
(reduce * (range 1 (inc n))))