PythonEDU 2017

Indices and tables

Brief Introduction to Python

So, you decided to take an introductory course on Python. That’s great! The neat thing about Python is how powerful it is yet at the same time how easy it is to figure out what the source code is doing, even if you have never studied the syntax.

Learning Python will provide a tool in your toolbox that can be used to rapidly develop many varied things. It’s not going to solve all your problems, and it isn’t the solution for everything, but, it is quite powerful:

  • You can write simple standalone command line scripts all the way up to large apps
  • You can write applications that have a GUI
  • You can write applications that are web based
  • You can write in many paradigms, including object oriented
  • You can easily write platform agnostic scripts / applications
  • You don’t have to worry about memory management as Python handles that for you
  • You don’t need to worry about the compiling and linking steps common to other languages.
  • The standard set of available functions/packages is quite extensive
  • It is easy to add additional functions/packages not available in the standard set.
  • You can embed Python IN an application

And it’s distributed free of nasty licensing encumbrances via the PSF license agreement.

Wikipedia maintains a nice list of software developments that are based on Python which gives an indication of the types of applications that can be created with it. Additionally, the Python Software Foundation has created a brochure that showcases Python’s use in various domains (business, science, media etc.). Those interested can get a copy of it here.

Python is an interpreted language, meaning your script gets compiled into bytecode (under the hood) and then executed by the Python virtual machine. The bytecode is platform agnostic making it seamless to run something on Windows, OS X or Linux.

Generally, even though it is interpreted, Python is pretty fast. But, if you need something to run really fast, you can create the function in C/C++ and call it from Python (mind you, that won’t be covered in this course).

Python was created by Guido Van Rossum; the “Guido” you will see commonly mentioned when reading about Python. He maintains an active role in Python’s development and is sometimes referred to as the Benevolent Dictator for Life (BDFL). Guido first released Python back in 1991 and has been continually evolving since then. That makes it very mature.

The guiding principles of the language are summarized in PEP 20, “The Zen of Python”, some of which is given below:

  • Beautiful is better than ugly
  • Explicit is better than implicit
  • Simple is better than complex
  • Complex is better than complicated
  • Readability counts

The entire text can also be brought up by executing the following Python easter egg:

>>> import this

Python is continually being enhanced through the Python Enhancement Proposal (PEP 1) process and vetted by the community before changes are implemented. Guido must sign off on all changes. Therefore, you can expect changes to generally be well thought out and not hacks.

Today, you can find 2 major versions of Python at play, v2 and v3:

  • python2 has been the workhorse for many years. A huge amount of software has been written that targets Python2. It is typically the default Python interpreter on Linux installs. However, it is deprecated for new development and Python2 is no longer being developed past v2.7.
  • python3 was released in 2008 to fix fundamental design flaws in the langauge. However these changes could not be implemented in a backwards compatible way so the version number was bumped. Python3 is recommended for all new designs.

This course will use python3.

Warning

python2 is by default typically called up with the command python, but python3 is usually called up with python3. Don’t forget this when running the interpreter and/or installing python or python packages or you may end up calling the wrong version.

As you learn the Python ecosystem, you will come across the term “Pythonic”. It’s the notion that there is an idiomatic way to do something using the Python language, which may not be how you would think to do it, or be able to do it, in another programming language. The courseware will try and call those out along the way.

While the course will cover a lot about Python, it is not going to try and cover everything. But everything about Python is documented over at the Python web site:

Finally, if you want to get involved deeper in the Python community, here are a few ideas:

  • Attend a PyCon (Python Convention). The PSF puts on PyCon’s all over the world throughout the year to promote the Python language through the sharing of knowledge and to encourage support and education across the Python community. PyCon’s typically have limited tickets that sell out quickly as they are well attended. Refer to PyCon Canada 2017 for an example.

  • Become a member of an online community, messaging board and/or newsletter. Some examples worth checking out are:

Hopefully, after taking this course, you will come to appreciate why Python is rated the top programming language of 2017 by the IEEE.

Practice, Practice, Practice

Fundamental to learning a new language is the ability to practice it. The course material is setup to teach a new topic and provide you with time and tools to practice along the way. To realize this, Jupyter-Notebook will be used along with this course material to allow you to explore and reinforce what has been taught, as you are learning it.

Please refer to the section, Environment Setup, for details on how to get started with Jupyter.