May 7th, 2008
I now uploaded the documentation for Jinja2 to the website for those of you who are eager and want to play with it :-) On jinja.pocoo.org you have now the choice to chose between Jinja1 and Jinja2.
The new docs are powered by Sphinx and Jinja2 with a custom templating bridge.
Read the documenation.
Tagged as: jinja, announcement |
No Comments »
Often I have an iterable i want to group. For example a list of integers and i want to process two at once. That’s a pretty nice idom I found in the documentation translated to itertools:
from itertools import izip, repeat
def batch(iterable, n):
return izip(*repeat(iter(iterable), n))
Use it like that:
>>> for key, value in batch([1, 2, 3, 4], 2):
... print key, value
...
1 2
3 4
May 7th, 2008 | Tagged as: snippets, python |
3 Comments »
This Makefile:
RSTOPTS=--time --link-stylesheet --stylesheet=style.css
SOURCES=$(wildcard *.rst)
HTML=$(foreach file,$(SOURCES),_build/$(basename $(file)).html)
all: html
_build/%.html: %.rst
rst2html.py $(RSTOPTS) $^ > $@
html: $(HTML)
clean:
rm -f $(HTML)
plus make html in .git/post-{commit.update} + python and docutils + a stylesheet in _build (all paths relative to your repository) is the perfect cross platform wiki :-)
Notice: my blog kills the tabs, copy/paste from the pastebin
May 2nd, 2008 | Tagged as: git, planetubuntu, snippets, python |
9 Comments »