Posts tagged: PYTHON

Neat new stuff in Python 2.5

I’m looking forward to Python 2.5. In particular:

  • Partial function application. One of my favorite things about Python is how amenable it is to a mixture of procedural, functional, and object-oriented styles. Learning a bit of Scheme last year put me in an especially functional mindset. Can wait to see what else gets rolled into the functional module in the future.

  • pysqlite in the standard library. The incorporation of SQLite into PHP5 (which goes a step further than Python, since it includes the SQLite binary itself) has been a great convenience. Many apps just don’t need a full relational database – and if they eventually do, much better to have started with SQLite than with BDB or some homegrown flat-file solution.

The twenty-minute trouble ticket system

People are always going on about how it “only” takes twenty minutes or whatever to knock together some little application. Screencasts don’t count, unless they are screencasts of somebody who hasn’t done any preparation. But damn, I just built a trouble-ticket system in Django in twenty minutes. Really. Of course, I already had a running install, this is just something I added. But it was instantly useful. I assigned four tickets to myself and now I can go have dinner.

Why the python.org redesign is good

I just posted this mini-rant over at reddit.com in response to implications that Python is somehow selling out by getting a more business-friendly makeover.

Here’s the thing about the new site being “too corporate” or whatever.

Python is not a band with a MySpace profile and an awesome debut album. It’s a programming language. Programming languages live if they’re used, and more or less die if they’re not used. Enthusiasts, e.g. reddit users, will find what’s cool regardless. Corporations, on the other hand, need to be marketed to. If you love Python, you should love the idea of it putting on a little bit of professional dress – because that ultimately means you are more likely to actually get paid to program in Python down the road.

Python.org redesign launches

This must have happened over the weekend. The redesigned python.org has launched. It’s a huge visual improvement over the old design, which really hadn’t changed much in, oh, about seven years.

The Python community has achieved a gradual, grudging acceptance of the idea that marketing and presentation matter, but I think it was Ruby on Rails that really drove it home. Ruby (a very cool language in its own right) has seen a huge surge in popularity in the past year, driven largely by the excitement around Rails. Python.org has been sitting around looking dowdy.

"Reverse" game update -- my language safari

My “Let’s play a game” post, featuring a simple number game implemented in three different scripting languages, has received many comments and updates in the few weeks it’s been up. There are now twelve implementations, seven written by me (wide variations in quality!) and five contributed by readers. The languages represented, as of today: Haskell, Io, JavaScript, Lisp, Logo, Lua, PHP, Prolog, Python, REBOL, Ruby, and Scheme.

I’ve learned a hell of a lot, and gotten some good ideas about which languages might be rewarding to dive into further. My favorite new discovery so far is Io. It’s clean, simple, consistent, and yet very pragmatic at the same time (e.g. lots of useful bindings, embeddable, etc.). The messaging syntax feels very natural, and the lack of brackets (cf. Objective-C) gives more than just visual relief: you don’t have to backtrack to the beginning of the expression to insert a bracket when you decide you need to chain one more message on the end.

Django development tips

Working on a couple Django projects in tandem has me tuning my approach to using the built-in development server. I thought I’d share some of the techniques I’m using.

Here are the commands I’m going to talk about. If you understand it all from these lines, you’re done!

screen -S projectname
./manage.py runserver |& tee -a logs/devserver.log
^A ^D
tail -f logs/devserver.log
screen -r projectname
screen -list

Using screen

screen -S projectname

The GNU screen command is incredibly useful for all kinds of things, including longish-running processes that need to be checked and tweaked and stopped and started – like your Django development server. (Read more about screen if this is new to you.)

Django: less (magic) is more

Today I updated my Django play/development environment to the new magic-removal branch, and migrated my proto-wiki as an exercise. Following the RemovingTheMagic instructions on the official Django wiki made it fairly easy. (I added some notes on dealing with custom template tags.)

This branch is about more than cleaning up some of the needlessly clever bits found in earlier implementations; it also has some really nice syntax refinements. Compare this:

reporters.get_list(fname__exact='John', order_by=('lname',))

to this: