HPR1138: Programming languages 2 - Python




Hacker Public Radio show

Summary: Programming languages 2 - Getting started with Python 1 Characteristics 2 Installation 3 Syntax and semantics 4 Interpreter 5 Standard library 6 Documentation and tutorials Python is a very interesting language in the sense that it covers a very wide range of use cases. It can be useful for simple scripting tasks, that is automating repetitive tasks that you usually do by hand. It can also be useful for text file processing, like parsing log files or specific formats like XML. You can use use it as a glue language, that is a mix of system calls to command-line programs, like in scripting, but also by calling foreing language libraries which provide Python bindings. You can use Python as a first language in a Computer Science curriculum, since it is simple to learn and supports different programming paradigms (Object Oriented, Procedural, Functional). You can it also as an extension language, since a Python interpreter can be embedded in C/C++ programs. Python being a very rich language with a very rich standard library, you can use it to build very complex applications. There are many ways of using it to build complex Graphical User Interfaces, since many graphical libraries provide Python bindings (http://www.diotavelli.net/PyQtWiki/PyQt4, GTK, etc.). Python also provides a default library for GUIs, which is called Tkinter and is based on Tcl/Tk. You can also use Python for web development, either by using the standard library utilities or by using one of the very popular web frameworks like Zope, Plone or Django. Finally, Python is also extensively used in scientific computing, since projects like SciPy, Numpy or Matplotlib provide a set of tools which allow Python to be as powerful as languages like Matlab or IDL with the advantage of being a full fledged language with a very rich standard library. 2 Installation There are 2 current versions of Python: version 2 and version 3. Version 3 is not fully compatible with version 2, so if you are starting with Python, I think is is wise to go with version 3, but be aware that most existing applications and Open Source projects use version 2. If you are using a GNU based system, chances are that Python is already installed in you system. Otherwise, it will be available in your distribution repositories. As far as I know, Python is also available on the Mac via the terminal. On widows, you will have to download a Python distribution from http://python.org/download. On this page you will also find links for downloading Python for Linux, MacOS, etc. If you go to this site, you will notice that they mention alternative implementations of Python. The implementation I will be talking about here is the one done in C. To install Python, you also can download the source code and compile it yourself. 3 Syntax and semantics Have a look at this link Python is intended to be a highly readable language. It is designed to