Python is a general-purpose programming language which promotes readability and rapid development. Python is widely used in science, mathematics, business, and web development. Both web and desktop applications are written in Python, with either graphical or command-line interfaces. A fully-featured, object-oriented language, Python is also suitable for procedural and functional programming paradigms. Python is cross-platform, free and open-source, and easier to read and write than other languages with similar features.
Python Language Specifics
Installation and execution
As a semi-interpreted language, a version of the Python interpreter must be installed in order to run any Python application. Developers most commonly acquire the desired version as distributed by the Python Software Foundation via Python.org. Python programs may be entered and executed line by line in an interactive prompt, or as files ending with the “.py” extension. A single file is referred to as a “module.” Python is visually recognizable by the meaningful use of whitespace to separate blocks of code. The import statement allows the execution of code from other modules, which is commonly used to change system state, or to make functions and classes available that are not defined in the current module.
Interpreter versions determine which features of the core Python language are available to a Python application, and how those features may be used. For example, a “print” statement may be called with the keyword print in Python 2, but in Python 3, the same behavior must be called as the print() function. Changes are made with the intention of more closely following Python Enhancement Protocols (PEPs). The first version of Python (1.0) was released by Guido van Rossum in 1991, with Python 2.0 released in 2000. Although Python 3.0 was released in 2008, the slow uptake of Python 3 by the community resulted in two incompatible versions in use for a number of years. Today, many legacy applications are maintained for Python 2 (usually 2.7), but Python 3 is now the accepted standard, and more popular. Developers are encouraged to use Python 3. Although Python 3 is not backward compatible with Python 2, fundamental concepts, types, and most keywords remain the same. Python 2 will no longer be supported starting in 2020. Applications are usually compatible between ranges of minor releases but not major releases, as Python 3.x is not backward-compatible with Python 2.x. For example, an application may specify Python 3.4+, meaning it will run with any of 3.4, 3.5, etc. Such an application would need significant changes to be executed in Python 2.7.
Although Python may be thought of as an interpreted language (code is compiled only at run-time), the standard implementation of Python (CPython) is written in C, allowing much of Python to be compiled prior to passing a statement to the interpreter. The CPython implementation has the effect of dramatically improving performance. Thus, developers may refer to Python as a “semi-interpreted” language. Additionally, because Python is a language specification rather than an implementation, there are many other implementations of Python including Jython (compiles to the Java runtime), PyPy, IronPython, and even MicroPython for microcontroller hardware.
Python is a dynamically and strongly-typed language. This means that an object need not be declared as a particular data type, but must be explicitly converted to other object types. Python will raise a TypeError up-front if an object is not explicitly converted instead of attempting to convert the object, as happens in weakly-typed languages.
Abstracted Memory Management
Like many higher-level languages, Python abst racts memory management such that it need not be handled explicitly in a Python application. Python implementations maintain a reference count to objects in memory, so that when the reference count is zero, memory is automatically freed for storage.
Python Vs Other Programming Languages
Python’s meteoric growth is generally attributed to its rapid development cycle, intuitive readability, and wide array of open-source packages, which sets it apart from other languages. As a fully-featured, object-oriented language, Python is most-often compared to Java and C/C++. In these comparisons, Python suffers in hardware performance, but excels at speed of collaboration and development. For example, although Java is not sensitive to whitespace, source code is more verbose and comparatively difficult to type and read, and may only be executed in the memory-intensive Java runtime. While C/C++ is far more effective in hardware performance and native desktop applications, the need to explicitly manage memory makes it less practical for prototyping, collaboration, learning, and web technologies.
Python Community and Ecosystem
Python is intended to be fun, lighthearted, and even whimsical – named as tribute to the British comedy group Monty Python. Example code often contains humorous references as variable names and values. An active community of developers creates and maintains powerful tools, such as Pandas, SQLalchemy, and Numpy, under the guidance of the Python Software Foundation (PSF).
Free and Open-Source
The Python language is free and open-source, as its license allows distribution for either free or commercial applications. Additionally, the source code for any package is usually distributed as human-readable text files, and may be changed or distributed according to its own license. Because Python applications are not distributed as compiled, executable files, they are not naturally obfuscated and may be easily read and uderstood.
Python Enhancement Protocols (PEPs) state principles which guide developers both in style and structural approach, specifically PEP 20 “The Zen of Python” and PEP 8 “Python Style Guide.” Accordingly, Python is known for two major concepts: the idea of pythonic code and the “Batteries Included” approach. The full collection of PEPs encompasses the history of the Python language and community. Code is pythonic when it follows the conventions of clarity and maintainability. Although Python is “self-documenting” (documentation strings may be accessed easily from command line applications), the community prefers readability through descriptive naming and and proper formatting. Additionally, Python language keywords are explicit and intuitive. The purposes of Lists and Dictionaries, for example, are easy for novices and experts in other fields to understand, compared to equivalent types in other languages. Pythonic code also refers to the idea that “there should be one—and preferably only one—obvious way to do it.” There are many ways to solve problems in Python, but the “obvious” solution will more closely follow language principles.
“Batteries Included” means that Python is distributed throughout a standard library of packages covering a wide array of use-cases, without requiring installation of third-party packages. Select libraries are installed along with the Python language to handle low-level tasks like threading, memory-management, and making connections via internet protocols. However, in practice, it’s common for a Python application to add third-party tools. Many professionals use Python because of specific tools and frameworks. For example, a Data Scientist may use Python solely to access the Pandas package for data analysis, or a Web Developer may use Python to implement a website with the Flask or Django frameworks. Taken together, the standard library and community packages distributed via the Python Package Index (PyPI) enable both novice and experienced developers to contribute effective, maintainable code.
Rapid Growth and Outlook