Skip to content

Latest commit

 

History

History
101 lines (66 loc) · 3.83 KB

File metadata and controls

101 lines (66 loc) · 3.83 KB

1 Overview. Installation. Basic Language Syntax

Overview.

Python is a general-purpose, interpreted, high-level, dynamic programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code compared to languages such as C++ or Java. The language provides constructs intended to enable writing clear programs on both a small and large scale.

Advantages of Python

Most of the advantage of Python involves his interpreted nature, but at the same time it offers a big set of options to develop:

  • Is Interpreted
  • Is Interactive
  • Is Object-Oriented
  • Is for Beginners
  • Can work as a Functional Language

Also the language by itself offers other advantages, beign intepreted allows the language to be:

  • Dynamic typed
  • Use of type inference
  • Allow explicit type definition as well as IMPLICIT typing
  • OS Independent

But not all can be sugar and honey, Python also has his disadvantages and they are explained next.

Disadvantages

Being interpreted makes the language great, but also makes the language to be slower or "interpreter dependant", which means that the language will work as fast as the interpreter do. However, let's add that you can fix this issue/problem recompiling the full interpreter to have better performance. Also, the interpreter by itself makes optimization on the fly like caching, making the language faster.

Another issue with the language are versions. Even if the language has not changed so much, Python 3 is a refactor from version 2 with no compatibility, motivated by a clean-up of issues that were beyond a simple deprecation. To get a better understanding of this change, I recommend Nick Coghland notes about why was Python 3 made incompatible with Python 2 and also What's New in Python 3 release notes from the official documentation.

This version subject makes you to decide about if you are going to work with Python 2, Python 3, a flavor of Python (like Jython or Cython or some hybrid beast that allows you to run pseudo python code mixed with other stuff). In general, Python 3 is encouraged, unless you are deploying to an environment you don't control, or working with a certain package not yet compatible with Python 3. And once you decide, you cannot mix (well, actually you can but is messy) Python 2 code with Python 3 code, as per the controversy detailed above.

Installing Python

If your OS doesn't provide you with a Python installation, you can get it from multiple sources.

  • Windows: Install it using an executable file, obtained from Python Website.
  • *NIX: Install using the package manager, get the commands and guides from Python Documentation.
  • MacOS: MacOS comes with Python 2.7 installed. Download a pkg file or using Mac Ports or Homebrew if you want to install Python 3.

You can have both Python 2 and 3 living in your operating system. You can set aliases to make python command to point to either version 2 or 3, as per your convenience.

Tools

pyenv

virtualenv

pip

easy_install

egg Files

Modules

Finding and Installing new modules

With pip

Without pip

Python Identifiers

Reserved Words

Indentation

Commenting

Python Scripts on UNIX/Windows

Python Editors and IDEs

  • PyCharm
  • Educational Edition
  • Community Edition
  • Professional Edition
  • Ninja-IDE

And that's it for just an introduction, now let's get real with the Labs and the Homework before getting into the second part of this course.