2012-05-10 20:44

If you haven’t heard about it, DreamPie is an awesome GUI application layered on top of standard Python shell. I use it for elaborate prototyping where its multi-line input box is a significant advance over raw, terminal UX of IPython.

However, up until recently I didn’t know how to make DreamPie cooperate with virtualenv. Because it’s a GUI program, I scoured its menu and all the preference windows, searching for any trace of option that would allow me to set the Python executable. Having failed, I was convinced that authors didn’t think about including it – which was rather surprising, though.

But hey, DreamPie is open source! So I went to look around its code to see whether I can easily enhance it with an ability to specify Python binary. It wasn’t too long before I stumbled into this vital fragment:

def main ( ) : usage = "%prog [options] [python-executable]" version = 'DreamPie %s' % __version__ parser = OptionParser ( usage = usage , version = version ) # ... opts , args = parser . parse_args ( )

The conclusions we could draw from this anecdote are thereby as follows:

It is indeed true that source code is often the best documentation…

…especially for open source programs where actual docs often suck.

With this newfound knowledge about dreampie arguments, it wasn’t very hard to make it use current virtualenv:

$ dreampie $(which python)

And after doing some more research, I ended up adding the following line to my ~/.bash_aliases:

alias dp='(dreampie $(which python) &>/dev/null &)'

Now I can simply type dp to get a DreamPie instance operating within current virtualenv but independent from terminal session. Very useful!

Be Sociable, Share!

















