python

iPython by brent

This interactive interpreter contains small upgrades to the default python interpreter.   Among others, native tab completion and a more bash like referencing of history commands. Install on OSX 10.5 with two simple commands:

[brent@ronin ~]501$ sudo easy_install ipython ... snip.... [brent@ronin ~]502$ sudo easy_install -f http://ipython.scipy.org/dist/ readline

Enjoy!

Pygame on OSX by brent

There are a few options for getting pygame running on OSX, namely, the MacPorts version and the version off of the Pygame site. The MacPort is available here. Note it's named py-game.  It has a huge number of dependencies.    Install this via the command:

sudo port install py-game

If it fails for you like it did for me, use the following:

Download the source ball from here. Follow their OSX instructions here with these caveats: - The MacPort package names are wrong in the instructions, use the following command instead:

sudo port install libsdl-framework libsdl_ttf-framework libsdl_image-framework libsdl_mixer-framework

- If you're running SVN 1.5, it isn't supported by the standard OSX python install of setuptools, meaning that pygame won't install. Run the following to remedy:

svn co http://svn.python.org/projects/sandbox/branches/setuptools-0.6 setuptools cd setuptools sudo python setup.py install

In theory, you're done! Download a good game to verify you've got everything running here (tgz file)

import this by brent

I love python for a lot of reasons, not the least of which are easter egg gems like this:

[brent@ronin ~]501$ python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import this The Zen of Python, by Tim Peters

Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! >>>

VIM settings for Python by brent

Here are a few VIM settings that have been helpful to me for python. This adds improved syntax highlighting: http://www.vim.org/scripts/script.php?script_id=790

Add the following to your .vimrc file. This is usually located in your home directory at ~/.vimrc

autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class autocmd BufRead *.py set tabstop=4 autocmd BufRead *.py set shiftwidth=4 autocmd BufRead *.py set smarttab autocmd BufRead *.py set expandtab autocmd BufRead *.py set softtabstop=4 autocmd BufRead *.py set autoindent