Ozan Onay's blog
Short pieces on python, django, and agile web development
-
Combining multiple forms in django
Conveniently, a django.forms.Form object is little more than a collection of fields, meaning that you can concatenate outputs to construct a single form in html, like so: <form action="" method="POST"> {{ form1.as_ul }} {{ form2.as_ul }} <input type="submit" /> </form> ...
Read full entryJan. 30, 2010 -
Nested list comprehensions and generator expressions in python
The list comprehension, and its under-utilised sibling the generator expression, are great tools for handling iteration with mapping and filtering in a compact manner. After all, compare: odd_lengthed_squares = [] for n in range(100): square = n * n if ...
Read full entryJan. 17, 2010