Python review

Course Overview

Python is one of the most popular and rapidly developing programming languages. A clear syntax which facilitates learning and a plethora of built-in and third-party libraries made Python especially popular among academics and researchers of all kinds. Python has already been the first-choice language in Machine Learning and Data Science for a while, but as far as Social Sciences are becoming more digitally-oriented it is getting in demand by sociologists, economists, linguists, and other social researchers. This course is created for students who want to learn how to solve real-world data-related problems with Python programming environment but have no experience in programming.

Some historacal facts about the Python

Fact #1

Python was created by Guido van Rossum [1] at the end of 1980th. In December 1989, Van Rossum had been looking for a "'hobby' programming project that would keep him occupied during the week around Christmas" as his office was closed when he decided to write an interpreter for a "new scripting language he had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers".

Guido entitled himself as Benevolent Dictator For Life, which means that he retain the final say in disputes or arguments within the community [2]. He had kept this title till July 2018, when retired from this post [3], tired after the fight for Python Enhancement Proposals #572.

Fact #2

Before creating Python, Guido was a contributor to the ABC programming language — a 10-year research project to design a programming environment for beginners. ABC introduced many ideas we now consider “Pythonic”: generic operations on sequences, built-in tuple and mapping types, structure by indentation, strong typing without variable declarations, and more. It’s no accident that Python is so user-friendly.

Here is am example function to collect the set of all words in a document:

HOW TO RETURN words document:
   PUT {} IN collection
   FOR line IN document:
      FOR word IN split line:
         IF word not.in collection:
            INSERT word IN collection
   RETURN collection

Fact #3

Guido van Rossum attributes choosing the name "Python" to "being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus)" [4].

Fact #4

Python has several incompatible versions — Python 2 and Python 3.

Features of Python

Very high-level programming language

A very high-level programming language (VHLL) is a programming language with a very high level of abstraction, used primarily as a professional programmer productivity tool. Very high-level programming languages are usually domain-specific languages, limited to a very specific application, purpose, or type of task, and they are often scripting languages (especially extension languages), controlling a specific environment. For this reason, very high-level programming languages are often referred to as goal-oriented programming languages [5].

General purpose scripting language

A scripting or script language is a programming language that supports scripts — programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator [6].

A general-purpose programming language is a programming language designed to be used for writing software in the widest variety of application domains (a general-purpose language). A general-purpose programming language has this status because it does not include language constructs designed to be used within a specific application domain [7].

Python is an excelent example of general purpose scripting language. See this endless list of software written with Python (it is not full yet).

Interpreted language

An interpreted language is a type of programming language for which most of its implementations execute instructions directly and freely, without previously compiling a program into machine-language instructions. The interpreter executes the program directly, translating each statement into a sequence of one or more subroutines, and then into another language (often machine code) [8].

In Python, the source is compiled into a much simpler form called bytecode. These are instructions similar in spirit to CPU instructions, but instead of being executed by the CPU, they are executed by software called a virtual machine [9].

How to stydy Python...

  • ... if you are a pedant 🧐: read documentation [11] and use help() function.
  • ... if you enjoy watching videos 🎥: join online courses like «Программирование на Python» [12] (I took many examples from this course), video lectures by Тимофей Хирьянов [13]. Thousands of them, really.
  • ... if you like "War and peace" 📚: read "Learning Python" by Mark Lutz [14] and "Python for Data Analysis" [15].
  • ... if you like video games 🕹: play Coding game and Kerbal Space Program.
  • ... if you are a girl 🙋‍♀️: join PyLadies SPb.
  • ... if you are easygoing and careless person 😜: cheat with cheatsheets like these from datacamp.
  • ... if you like to read blogs 💻: subscribe to Planet Python, Real Python, Python Tips and more.
  • ... if you like to chat with people in the real world 👫👬🚶‍♂️: join SPb Python or PiterPy communities and visit associated meetups and conferences.
  • ... if you are a student of HSE 👩‍🎓: just keep reading, you are at the right place.

Programming enviroments

  • Text editors: Sublime text 3 (my choice), Atom, Notepad++, Vim...
  • Interactive console, IPython.
  • IDEs: PyCharm (most advanced IDE), IDLE.
  • Enviroments for researchers: Jupyter, Rodeo, Spyder.

References

  1. Guido van Rossum. (2019). In Wikipedia. Retrieved from https://en.wikipedia.org/w/index.php?title=Guido_van_Rossum&oldid=877294641
  2. Benevolent dictator for life. (2018). In Wikipedia. Retrieved from https://en.wikipedia.org/w/index.php?title=Benevolent_dictator_for_life&oldid=876029638
  3. Rossum, G. van. (2018, July 12). [python-committers] Transfer of power. Retrieved from https://mail.python.org/pipermail/python-committers/2018-July/005664.html
  4. Foreword for “Programming Python” (1st ed.). (n.d.). Retrieved January 12, 2019, from https://www.python.org/doc/essays/foreword/
  5. Scripting language. (2018). In Wikipedia. Retrieved from https://en.wikipedia.org/w/index.php?title=Scripting_language&oldid=875767169
  6. General-purpose programming language. (2019). In Wikipedia. Retrieved from https://en.wikipedia.org/w/index.php?title=General-purpose_programming_language&oldid=876946020
  7. Interpreted language. (2018). In Wikipedia. Retrieved from https://en.wikipedia.org/w/index.php?title=Interpreted_language&oldid=869247623
  8. Ned Batchelder. (2018). Is Python interpreted or compiled? Yes. Retrieved January 12, 2019, from https://nedbatchelder.com/blog/201803/is_python_interpreted_or_compiled_yes.html
  9. David Robinson. (2017, September 6). The Incredible Growth of Python | Stack Overflow. Retrieved January 12, 2019, from https://stackoverflow.blog/2017/09/06/incredible-growth-python
  10. 3.7.2 Documentation. (n.d.). Retrieved January 12, 2019, from https://docs.python.org/3/
  11. Программирование на Python. (n.d.). Retrieved January 12, 2019, from https://www.coursera.org/specializations/programming-in-python
  12. Тимофей Хирьянов. (2018). Алгоритмы на Python 3. Лекция №1. Retrieved from https://www.youtube.com/playlist?list=PLRDzFCPr95fK7tr47883DFUbm4GeOjjc0
  13. Lutz, M. (2013). Learning Python, 5th Edition (Fifth edition). Beijing: O’Reilly Media.
  14. McKinney, W. (2012). Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython. O’Reilly Media, Inc.

Comments