Why learning python by individual training courses. Courses on python programming, python scripting courses by RasadaCrea - Grenoble Lyon France

Skip header | smaller text web accessibility bigger text web accessibility | easy print web main content share this web document with a partner

Why choosing Python as your programming language

learning python programming, python courses, python hands-on training, python individual courses

How to choose a valuable programming language

There are a large number of programming languages, each with its advantages and disadvantages. We must choose one. Some are linked to programming environments, ie proprietary software, while others do not offer a set of usability, robustness and power. The dominant language is probably the C/C++. This language is an absolute reference, and every programmer might have to rub it sooner or later. Unfortunately, it is very daunting and complicated, too close to the machine. Its syntax is not really readable and very demanding. The development of a large program written in C/C++ is long and painful. The same applies also to some extent for the Java language.

On the other hand, the modern practice of this language makes extensive use of application generators and other support tools such as sophisticated C++Builder, KDevelop, etc.. These programming environments can certainly be very effective in the hands of experienced programmers, but they are based on far too complex tools; they presuppose on the part of the user advanced knowledge that a beginner does not master.

Furthermore, the use of a higher level language, less restrictive, with a more readable syntax seems an excellent choice for a wide range of programming tasks. Among these languages​(such as Perl, Ruby ..), Python is a very modern one, fast growing in popularity.

Presentation of the Python language

Python is a portable language, dynamic, extensible, free, which allows but does not require a modular and object-oriented programming. Python has been developed as open source software since 1989 by Guido van Rossum and many software programming volunteers.

Benefits of Python programming language

The main features (and resulting benefits) of the Python programming language (and its two implementations), can be listed as it follows:

  • Python is portable, not only on the various flavors of unix, but also on commercial operating systems: MacOS, BeOS, NeXTStep, MS-DOS.. and the various variants of Windows
  • Python is free, but it can be used without restriction in commercial projects
  • Suitable for both small Python scripts of a few lines of code and complex projects of tens of thousands of lines
  • The Python syntax is very simple and, combined with advanced data types (such as lists, dictionaries ..), led to programs which are very compact and readable. At equal functionality, a complete Python program is often 3 to 5 times shorter than a C or C++, or even Java, representing an overall development time of 5 to 10 times shorter and greatly increased ease of maintenance
  • Python manages its resources (memory, file descriptors ..) without programmer intervention, by a reference counting mechanism (similar to a garbage collector). There are no explicit pointers in Python
  • Python is multi-threaded and multi-processing
  • Python is object oriented. It supports multiple inheritance and operator overloading. In its object model, and by taking the C++ terminology, all methods are virtual
  • Python Integrates, like Java or newer versions of C++, a system of exceptions handling, which can greatly simplify error control
  • Python is dynamic (the interpreter can evaluate strings representing expressions or Python statements), orthogonal (a small number of concepts is sufficient to generate structures very rich), reflective (it supports meta-programming, for example the ability for an object to add or to remove attributes or methods, or even change class running) and introspective (a large number of development tools, such as "debug" or "profiling", are located in Python itself)
  • Like Scheme, or Smalltalk, Python is dynamically typed. Any object used by the programmer has a well-defined type at runtime, with no need of any variable advanced declaration
  • Python currently has two implementations. One, written in C (interpreted implementation), in which Python programs are compiled into portable instructions, and then executed by a virtual machine (like Java, with one important difference: Java is statically typed, therefore it is much easier to accelerate the execution of a Java program than a Python program). The other, JPython, is written in Java and generates Java bytecode directly
  • Python is extensible: as Guile or Tcl; we can easily interface with existing C libraries. One can also use it as an extension language for complex software systems
  • The Python standard library, and contributed packages, provides access to a wide variety of services: strings and regular expressions, standard UNIX services (files, pipes, signals, sockets, threads ..), Internet protocols (Web , News, FTP, CGI, HTML ..), data persistence and databases, graphical interfaces
  • Python is a language that continues to evolve, supported by a community of enthusiastic users and managers, most of whom are supporters of open source software
  • Finally, Python is a language of choice for processing XML documents

Python language versions

Python continues to evolve, but this trend is only intended to improve the language. We will not have to change all our programs to fit a new version that would become incompatible with an earlier one. However there are two development branches: Python 2.x and Python 3.x.

Although Python 3.0 is released shortly after version 2.6, and version 3.1 and 3.2 have been made available in the meantime, few developers have fully switched to the Python 3 branch. This is due to various reasons. The first is that Python 3 has so far brought very few new functionalities, but requires modifying the source code of a project initiated under Python 2.x. The second is that all the major libraries are not yet available for Python 3 branch.

Finally, from the perspective of developers of Python, there were two branches in which new features were added (for instance 2.7 and 3.2), plus two maintenance branches (2.6 and 3.1). In most cases, each commit should be replicated in four branches, which has a significant cost (although some tasks are automated) because the code of each branch has more or less diverged.

Now the new features will be developed only in Python 3 branch. Efforts will therefore concentrate to make latest version more attractive and help porting to Python 3. For example one can view a list of new functionalities Python 3.2 branch. Feature changes in the Python language are handled by the procedure PEP (Python Enhancement Proposals): PEP contains the index of all proposals improvement of Python.

The Python 2to3 conversion tool

2to3 is a Python program that reads Python 2.x source code and applies a series of "fixers" to turn it into valid Python 3.x code. The standard library contains a rich set of fixers that will handle virtually all of the code variations. 2to3 uses the library lib2to3, which is a flexible and generic library, so it is possible to write its own "fixers" 2to3. lib2to3 could also be adapted for custom applications in which Python code can be edited automatically.

2to3 is usually installed with the Python interpreter as a script. It is also located in the directory tools/scripts of Python root. The main arguments of the script 2to3 include a list of files or directories containing code to convert. Directories are recursively traversed to search any Python source files. Here is a sample code in Python 2.x, located in file example.py:

def hello(name):
    print "Hello, {0}!".format(name)
print "The name is:"
name = raw_input()
hello(name)

It can be converted to Python 3.x code with the 2to3 command line script:

$ 2to3 example.py

This command prints to the terminal a diff format information related to differences with the original source file, without actually modifying the source file. 2to3 can also write the changes into the source file with the -w option. In this case the original source file is saved with a .bak extension (though by adding the -n option no backup file is produced):

$ 2to3 -w example.py

After transformation, the example.py source file looks like this:

def hello(name):
    print("Hello, {0}!".format(name))
print("The name is")
name = input()
hello(name)

By default, 2to3 performs a series of preset "fixers". The -l option lists all the available "fixers". An explicit set of "fixers" to be used can be given with the -f option. Similarly, the -x option explicitly disables a "fixer". The following example runs only fixers import and has_key:

$ 2to3 -f imports -f has_key example.py

Individual training and Python learning programming courses by RasadaCrea

All Python programming courses taught by RasadaCrea are individuals and personals. Contact RasadaCrea for more information about creating your personalized Python programming training plan, as well as for prices and organization of the Python learning programs.