The features of the Python programming language are summarised below:
- It is an interpreted language , not compiled , it uses dynamic typing , strongly typed .
- It is cross-platform , which is advantageous to make its source code executable between various operating systems.
- It is a multiparadigm programming language , which supports various programming paradigms such as object-oriented , structured , imperative programming and, to a lesser extent, functional programming .
- In Python, the format of code (eg, indentation) is structural.
The strongly typed means that the type of value does not change suddenly. A string that contains only digits is not magically converted to a number. Each type change requires an explicit conversion. Here is an example of this concept:
# varible "value1" is integer, varible "value2" is string value1 , value2 = 2 , "5" # the int () method is to convert to integer total = value1 + int ( value2 ) # the str () method is for convert to string print "Total is:" + str ( total )
The dynamic typing means that objects at runtime (values) have a type, unlike the static types where the variables have a type. Here is an example of this concept:
# "variable" stores a value integer variable = 11 print variable , type ( variable ) # "variable" stores a value string variable = "active" print ( variable ), type ( variable )
Python is cross-platform , which is advantageous to make its source code executable between several operating systems, that is, it supports the following platforms for its execution:
Python versions for Microsoft Windows (and DOS) (x86 / x86-64 architecture in executable layout, Zip file, web-based installer).
Python versions for Mac OSX (Macintosh) (32bit / 64bit architecture in executable installer presentation).
Python versions in source code (tarball file of the source code compressed with XZ and with Gz). For most Linux / UNIX systems, you must download and compile the source code.
Versions of Python on other platforms , the “traditional” version of Python (it has a code name
CPython), but this version has been migrated to a number of specialized and / or older platforms, some of them are highlighted below.
- Pythonista , Python for iOS, offers a complete development environment for writing Python scripts on your iPad or iPhone.
- ActivePython , Python for Solaris, You can buy it (commercial and community versions, including scientific computing modules, not open source), or compile from source if you have a C compiler. UNIX packages have a variety of Python versions for a variety of Solaris releases. These use the Sun standard
Be aware that these migrations are often far behind the latest version of Python.
Philosophy “Includes batteries”
Python has long held this “batteries included” philosophy:
“To have a rich and versatile standard library that is readily available. Without the user downloading separate packages. “
This gives the language an advantage in many projects.
The “included batteries” are in the Python standard library .
It is a collection of 20 software principles that influence the design of the Python Programming Language, of which 19 were written by Tim Peters in June 1999. The text is distributed as the public domain.
The Zen of Python is written as Informational Post # 20 in the Python Enhancement Proposals (PEP ), and can be found on the official Python site.
The principles are listed below:
- 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.
- Scattered is better than dense.
- Legibility counts.
- Special cases are not so special as to break the rules.
- The practical beats the pure.
- Mistakes should never be allowed to pass silently.
- Unless they have been explicitly silenced.
- Faced with ambiguity, reject 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 are Dutch.
- Now is better than ever.
- Although it is often never better than right now.
- If the implementation is difficult to explain, it is a bad idea.
- If the implementation is easy to explain, it might be a good idea.
- Namespaces (
namespaces) are a great idea. Let’s do more of those things.