>>> print "".join(" hello world ".split())
helloworld
The key to the above is that split()
separates the string on
any amount of whitespace when no separator is specified.
Posted on in Programming
Posted on in Programming
Background: While cleaning up my development directory the other day, I renamed one of my Django project directories to the domain name of the site. For the sake of argument, we'll call it django.slaptijack.com. When I descended into the directory and tried to start the development server, I …
Posted on in Programming
If you're like me, you're probably really excited about the changes coming in Django 1.2. The good news is that, as of April 7th, there are only 14 outstanding issues in the Django 1.2 release candidate. Of those 14 remaining issues, it sounds like one in particular is …
Posted on in Programming
If you've ever built a site that has different kinds of users, you've probably run across the case where you want a limited number of users to appear in a particular list. For example, you may only want staff members to be assigned ownership of a particular object. If your …
Posted on in Programming
If you get this error when trying to save something in the Django admin, it's probably because you forgot to synchronize the database after adding the admin application. If you are using a pre-1.2 version of Django, you can simply:
$ ./managy.py syncdb
Django 1.2 (which is currently …
Posted on in Programming
FYI, this post is out of date. As of Python 3.0, universal newline mode is now
the default and 'U'
is accepted, but no longer does anything.
I deal with a lot of people that prefer to open reports in Microsoft Excel. I've gotten used to generating CSV (comma …
Posted on in Programming
For some reason, sorting a dictionary by its keys seems to be one of the most frequently asked Python questions. I'm not sure if this is because it's just much easier to do in other languages, or if the semantics of the language just confuse new Python developers. I guess …
Posted on in Programming
In a word, you can't.
Django was designed to keep the template system separate from the coding. This means that Django templates are mostly HTML with a bit of Django template code interspersed. This is very different from PHP where HTML and code are very tightly bound. Separating HTML development …
Posted on in Programming
If you've been following along, you are probably already aware the Pinax team has decided to make some radical changes to their directory structure based on input from users. I took the time to update my own Pinax project — let me show you what's changed.
First, here's the new directory …
Posted on in Programming
I mentioned previously that I'm working on a Pinax project. Email notifications are one of the things you need to get working in your development environment. Unfortunately for the novice Django developer, getting this working may not be obvious.
<!--more-->
Pinax uses an application called django-mailer to handle outgoing email …
Reading Now
Other Stuff