Moved (again)

This website has moved to ArtfulCode.net.
|

On hiatus

With the birth of my daughter, I have not had much chance to keep up with Artful Code. I apologize to those who read regularly, and I will begin posting new articles as soon as possible.
|

Partial Application and Currying

Currying, known in Python land as partial application, is a technique in which a function taking multiple arguments composes a function that takes fewer arguments (in most languages, reducing to one, although this is not the case in Python) by partially applying it to given parameters. For example, a function, sum, might be used to compose a new function called "plus_one" by currying it with the value of one. The composed function is not evaluated; it is returned as a function object which may then be applied to other parameters. Read More...
|

Multi-threading in Python

Programming with threads is one of the more difficult tasks in programming. The Python threading and Queue modules make this significantly easier, but it still takes some deliberation to use threads in an efficient way.

Python's thread and threading libraries use POSIX threads. The threading library is the higher level of the two and is therefore the one to use in your typical programming tasks. The Queue module provides a thread-safe mechanism for communicating between threads, like a combination list and semaphore. Read More...
|

Dynamic URLs in Django

I long ago switched my company's web applications from Code Igniter to Django. The main reasons were Django's more powerful database API and Python's maintainability and scalability over PHP. The only feature of Code Igniter that I really miss in Django is the ability to add a page without first registering the url, formulating a regular expression to describe the parameters and variations of the view function, and then creating the view and template.

For a production website, this is a better method than Code Igniter's strategy of http://domain.com/class/method/arg/arg/.../, but CI's is much easier during development. My urls may change half a dozen (or more) times in the course of the project, especially if marketing or advertising is involved. Fortunately, there is an easy fix. Read More...
|