Skip to content
Calvin J Lin edited this page Feb 12, 2021 · 5 revisions

The primary language we use in the IELaboratory is Python. This page should help get you up and running with some introductory materials and some more advanced information.

python_banner

Getting Started

Some references to explore:

Written by Tim Peters, the Zen of Python is a set of 20 guiding principles (of which 19 have been written) for writing code in Python and has been codified in PEP-20 (Python Enhancement Proposal). An easter egg is that if you type import this in any python script or interpreter, the Zen of Python will be displayed.

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

The general guideline used by most Python developers for formatting code is detailed in PEP-8. Some of the topics include:

  • Maximum line length
  • Capitalization in naming
  • Use of spaces

Multiple python packages exist to help automatically format your code for you including: black, google's yapf, autopep8. They can be installed through the pip or conda package manager.