Python Programming Language...Knowing it
Guido van Rossum invented the python programming language. One of the founding goals of python as stated by Rossum is
“Create better, easier to use tools for program development and analysis.”
Python being one of the top 10 programming languages of today has evolved rapidly. Python has enabled computer users around the world with rapid software development process.
Python Software Foundation takes care of the development process of Python as well as the Evolution of Python.
Hello World Program in Python
The python interpreter executes Python programs. The python interpreter can be invoked by typing python from the console window.
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
The invoked python interpreter acts as an interactive console as well. Python program blocks can be executed directly input directly in the console window.
The Python programs can be saved in a file with .py extension and can be executed with the python interpreter.
The same print statement above, executed in the python interactive console can be executed from a HelloWorld.py as well. Just open your favorite text editor and enter
in a text file. Save the file as HelloWorld.py.
The python statements entered individually in the python interactive console will be lost at the closing of the session. Hence any reusable python program can be stored as a .py file and executed several times as per the need.
Entry point of a Python Program
Python’s entry point function mechanism of a program is simple and different from languages like C, C++ and Java. The first function invoked in a python file that is being executed becomes the entry-level function of the python program.
The __name__ variable is available inside any python module as the name of the module. However, __name__ will be set to __main__ in case if the module is under execution.
A python module is the file containing python code: It could include invocations, definitions or both.
The Python Interpreter and Python Byte Code
The python interpreter interprets python statements in a python program into python byte code and executes them.
A Python program is different from a C Program or a C++ Program in terms of how it is executed.
A python program is typically not directly translated into machine code. Instead it is translated into byte code and executed. A Python program is slightly different from the execution of a Java program. When a python program is executed the byte codes are typically not stored in the file system like a Java .class file. The Python interpreter on the fly generates the byte code for a python program every time it is run.
However when .py file is executed, if the python program imports one or more modules then for each imported module byte code will generated in the form of a .pyc file and stored in the file system. However if the developer wants to generate .pyc file for the python program as well, then it can be done using py_compile module.
Running the above program with python interpreter produces the .pyc file inside the __pycache__ folder.
Remember, in general, neither the python program text nor the byte code generated from python programs can be directly executed on any machine. Python program execution is always through the python interpreter.
Python Interpreter – Little Implementation Details
The standard python interpreter is written in C language and the implementation is popularly known as CPython. There are Python implementations developed using other languages as well:
Language in which Python interpreter is written
Name of the Python interpreter
RPython(translated into C)
Applications of the Python Programming Language
Python is a high level programming language.
Python is widely used for
- Web site development
- Text Processing
- Scientific Data processing
- UX development
and much more. Here is an elaborate list of Applications of Python Programming Language.
The current major version of the Python Language is version 3.0.x