Dugan Chen's Homepage

Various Things

A Point Free Function Composition Operator For Python

Here’s a quick implementation of a point free function composition operator for Python: The composable class works as a function decorator: The following test prints out “dcba”, which is what you would expect if you start with “d”, append “c” to it, append “b” to it, and then append “a” to it: One use case […]

Rendering Django forms for the Twitter Bootstrap

There seem to be dozens of projects to integrate Django with the Twitter Bootstrap. All of them seem to be large enough to need permanent homes on GitHub. If all you need to do is render a form the way Bootstrap expects, however, then the process is easy. The total amount of code needed is […]

Django ModelChoiceFields as autocomplete lists

Every Django user knows about its ModelChoiceFields. Pass them to a form template, and they render as HTML Select elements via which a user may choose an ORM moodel. Use them for form binding, and they’ll find you, from the form POST data, the ORM model that the user chose. But what if you don’t […]