Python

Web programming utilizes a broad range of programming resources and technologies, including Javascript, PHP, ASP, and MySQL. Tethys Platform brings together a wide variety of web programming tools and resources and integrates them using a single primary language: Python. This is accomplished using the Django framework - one of the building blocks of Tethys. Python is an excellent choice for an integrating language because Python has evolved to the language of choice for scientific programming and there is a huge library of Python resources freely available on the web. If you ever get stuck on a new project, chances are you can google some sample Python code or a custom Python library in a few seconds.

Python Resources

There is a vast set of resources on the web for learning Python. The main Python website maintains a useful list:

https://wiki.python.org/moin/BeginnersGuide/Programmers

If you are interested in a free electronic textbook for learning Python, this is a classic:

http://interactivepython.org/runestone/static/thinkcspy/index.html

Python Package Management

As you learn about Python, you will notice that Python code is organized into modular libraries. There is a huge number of libraries available and they are constantly changing. Furthermore, each library can be dependent on specific versions of other libraries. Keeping all of these dependencies straight can be daunting. Fortunately, package managers can do all the work for you. Tethys uses a package manager called Conda. This is important enough that it is one of the learning modules in this sequence:

Package Management with Conda

We recommend you install and use Conda to maintain your Python libraries.

Text Editors and IDE's

When you are writing code for Tethys, you will typically edit your code using a text editor or an Integrated Development Environment (IDE). A text editor allows you to do simple editing of the Python code. An IDE provides text editing capabilities, but also provides pretty printing (automated code formatting), debugging, error checking, etc. Some popular text editors and IDE's:

PyCharm - Get the community edition. Free and it has most of things you need.

Sublime - A powerful text editor that supports Python scripting

Spyder - Ditto

Jupyter Notebook

Jupyter Notebook is a Python programming environment that allows you to organize your code in short snippets called "cells" and run the code a few lines at a time and the output is captured in the notebook. It is an excellent way to write Python code as you are learning to program and it also works as a "sandbox" as you prepare algorithms to then embed within a Tethys app. This is also a separate learning module in this sequence:

Python Programming with Jupyter Notebook

 

BYU Hydroinformatics Group

Brigham Young University
Dept. of Civil and Environmental Engineering