In the realm of computer programming, there often arises a need to automate tasks. This could range from performing a search-and-replace over a large number of text files, renaming and rearranging a bunch of photo files in a complicated way, to writing a small custom database, a specialized GUI application, or even a simple game.
Professional software developers often have to work with several C/C++/Java libraries and may find the usual write/compile/test/re-compile cycle too slow. Writing a test suite for such a library can be a tedious task. In such scenarios, Python emerges as the perfect solution.
Python is simpler to use, available on Windows, macOS, and Unix operating systems, and helps get the job done more quickly. While it is simple to use, Python is a real programming language, offering much more structure and support for large programs than shell scripts or batch files can offer. It also offers much more error checking than C, and being a very-high-level language, it has high-level data types built in, such as flexible arrays and dictionaries.
Python allows you to split your program into modules that can be reused in other Python programs. It comes with a large collection of standard modules that you can use as the basis of your programs. Some of these modules provide things like file I/O, system calls, sockets, and even interfaces to graphical user interface toolkits like Tk.
Python is an interpreted language, which can save considerable time during program development because no compilation and linking are necessary. The interpreter can be used interactively, making it easy to experiment with features of the language, write throw-away programs, or test functions during bottom-up program development. It also serves as a handy desk calculator.
Python enables programs to be written compactly and readably. Programs written in Python are typically much shorter than equivalent C, C++, or Java programs, for several reasons:
- The high-level data types allow you to express complex operations in a single statement.
- Statement grouping is done by indentation instead of beginning and ending brackets.
- No variable or argument declarations are necessary.
Python is extensible: if you know how to program in C, it is easy to add a new built-in function or module to the interpreter, either to perform critical operations at maximum speed, or to link Python programs to libraries that may only be available in binary form. Once you are really hooked, you can link the Python interpreter into an application written in C and use it as an extension or command language for that application.
By the way, the language is named after the BBC show “Monty Python’s Flying Circus” and has nothing to do with reptiles. Making references to Monty Python skits in documentation is not only allowed, it is encouraged!
Now that you are all excited about Python, you’ll want to examine it in some more detail. Since the best way to learn a language is to use it, the tutorial invites you to play with the Python interpreter as you read. So, let's dive in and explore the world of Python!