Hacker News new | past | comments | ask | show | jobs | submit login

Great post. I would add:

* the site module, which is imported by default and is what is responsible for setting up the default sys.path. You can skip 'import site' by running python with the -S switch. the site module is written in python, so you can scan through it and understand how python starts up and inits.

* PYTHONSTARTUP env variable, which points to a python file that is run (like a bashrc, or AUTOEXEC.BAT, if you prefer) on interactive prompt startup. I use this to import custom paths and modules that I want to access from the REPL, such as Google App Engine

* I use pip with local repositories. clone the repos of the libs you need, and then pip install in the virtualenv from that local clone:

    $ pip install git+file:///Users/nik/.python-packages/tornado
(note the triple slash). Or straight from GH:

    $ pip install git+git://nikcub@github.com/nikcub/tornado
this can keep your versions in sync across all projects and virtualenvs and it means no re-downloading and you can setup and update projects while offline.

* don't store the actual project inside the virtualenv. the virtualenv provides the execution context (setup and torn down using the virtualenvwrapper helper scripts). a common practice is to place all your virtualenvs into a directory like ~/.virtualenvs. you should never have to cd into this dir, access it using the wrappers and pip. (edit: also agree with comment below that you shouldn't be sudo'ing).

* just a quick add, I think it is definitely worth learning how to install python from source.




PYTHONSTARTUP also lets you enable things like

  * coloured prompt
  * tab-completion
  * persistent history
Here's mine: http://mg.pov.lt/pythonrc




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: