This is very easy and allows you to have multiple Python versions without messing with system python interpreter (which is used by a lot of Ubuntu own programs). On my dev machine I have literally dozens of different Python versions from 2.4 to 3.2 living happily in /opt.
we need C compiler and other stuff to compile Python
sudo apt-get install build-essential
SQLite libs need to be installed in order for Python to have SQLite support.
sudo apt-get install libsqlite3-dev
sudo apt-get install sqlite3 # for the command-line client
sudo apt-get install bzip2 libbz2-dev
Download and compile Python:
tar xJf ./Python-3.3.5.tar.xz
make && sudo make install
Some nice touches to install a py command by creating a symlink:
And this is it. Now you can have any Python version, even an alpha, or, say, to have a few copies of Python 3.3 compiled with different settings... not that many people need that though :)
There's a software called pyenv which may help you to automate the procedure - what it essentially does is compile Python from source, installing it in your home directory. Its goal is to help you manage multiple Python versions.