I make apps for other people

Posts made on Thursday, November 19th, 2015

How I code Python with tests

Posted by Chris Jones
On November 19th, 2015 at 13:25

Permalink | Trackback | Links In |

Comments Off on How I code Python with tests
Posted in Python

Setting up the project and where to put the code

  1. Project creation

    I use virtualenv to create the project. If I’m using a different version of Python than the system default, I can specify the interpreter version when creating the environment.

    $ virtualenv -p /opt/local/bin/python2.7 my_project

  2. Environment activation

    Before I can do anything with the environment, I need to activate the environment.

    $ source myproject/bin/activate

  3. Installation of modules

    By default, virtualenv installs pip to allow me to download and install Python libraries in my environment. Depending on what I’m writing, I need to pick out libraries that are needed to complete the project.