Skip to Content

Background about changes in our software for fall 2017

As of 2017, the Physics computional language platform is the Anaconda distribution of Python 3, which is an open source package that is hosted by Anaconda, Inc. (formerly Continuum Analytics, Inc.).

Before September 2017, U of T Physics distributed a custom Python 2 package based on different source distributions. We did this to maintain back compatibility with legacy software and because of a lack of suitable alternatives. We switched to Python 3 to keep up with the times and to line up with how Python is used and taught elsewhere at U of T. We made the move to Anaconda Python because it's easy to install on different computer platforms (Windows/Mac/Linux), to update and extend, and to configure in multiple ways for specialized applications. Anaconda has a large and active user community, which helps ensure that Anaconda python packages will keep up with changes to hardware and operating systems. This means that the packages will be easy to install and set up.

The continuum.io website describes Anaconda as the "the leading open data science platform powered by Python" and as you get to know the distribution we hope you will see that the tools included with Anaconda extend well beyond the python packages we focus on at compwiki.physics. As always with the tools we describe here at compwiki.physics, it's a free toolkit that you can take anywhere and use in your future life as a Working Physicist.

Working in Python requires a running interpreter (shell) where you type and execute commands and an editor where you can edit plain-text scripts that the Python interpreter executes. The interpreter and editor can be run separately but often are combined into an Integrated Development Environment (IDE). Anaconda Python includes several IDEs such as IDLE, Jupyter Notebook, Spyder, etc. -- feel free to check them out. Some people prefer using a simple terminal program and a plain-text editor for their programming. It's really up to you.

As of September 2017 local documentation assumes use of the Spyder IDE which is a simple and powerful IDE suitable for our Physics students. We will show you how to get started with Spyder but at any time you can switch to any IDE or terminal+editor option you prefer.

Some notes on converting from Python 2 to Python 3

One consequence of the migration to Python 3 is that the older Python documentation on the compwiki website might not be compatible with Python 3. Here are a few tips to help you make sense of some of the older documentation and convert some of your older programs:

  • Whenever you see a print statement of the form print "string", val enclose it in parentheses as in print("string", val)
  • Whenever you see a Python 2 division statement, you will need to carefully analyze the code to determine whether integer division ( // in Python 3) or floating point division (/ in Python 3) is required.
  • The input() command is implemented a bit differently in Python 3 compared to Python 2. In particular, you will typically need to convert the result of input() to the appropriate data type such as float() or int(), as in
python code
            age = int( input( 'Please enter your age in years and press return. '))
        

  • String formatting from Python 2, e.g. "The value of pi is %f"%(math.pi) still works, but Python 3 has a superior string format which we recommend using.
  • The older documentation used the simple IDLE and VIDLE development environments; the appearance of windows and prompts may be quite different from Spyder.
  • Anaconda Python 3 is not compatible with VPython (which is imported using the visual module). If you are planning to use VPython you will need to install a separate Python 2 distribution.