May 9, 2011, 4:28 p.m.
posted by kudio
WHAT IS IT GOOD FOR?
Unsurprisingly, with such wide support and extensive features, Python is very effective for a large number of tasks. Here's a quick list of the some of the more common uses of the Python language.
Python supports an extension called NumPy that provides interfaces to many standard mathematical libraries. The Python language also supports unlimited precision. If you want to add two 100-digit numbers together, you can do so without requiring an external or third party extension.
Python can split, separate, summarize, and report on any data. It comes with modules that separate out the elements of a log file line, you can then use the built-in data types to record and summarize the information before writing it all out again. In addition, Python comes with regular expression libraries that allow you to use the same expressions as emacs, Perl, and many other utilities. This means that Python can do all of the things that other languages can do – one programmer even produced a complex SGML processing tool using Python to handle a large documentation project.
Rapid application development
Because Python is so straightforward to program, we can use Python to develop applications very quickly. The extensive module library that comes with Python provides direct interfaces into many of the protocols, tools, and libraries that you would otherwise have to develop.
Also, because Python natively supports Tk you can do more than just an interface example. It is not uncommon for many people to develop the entire application in Python in hours instead of the days it would take using C/C++. I've written a cross platform, Tk-based database query tool in less than a day, something that would have taken me two or three days with Perl, and a week or more in C.
We already know that Python supports a wide range of platforms in a completely neutral format. You can use Python to develop an application to be deployed across a network that uses a variety of different platforms. You can also use Python where you want to be sure that future implementations of your system are going to work. Many companies start with a specific platform and then move to a different platform as the performance starts to suffer. Using Python you will never need to re-write your software as you move between platforms.
Of course, you can also look at Python as an alternative when supplying software to end-users. Instead of developing three separate applications you only have to develop it once, saving significant time and money.
Although much of the ethos with Python is to hide you from the low-level parts of the operating system, the tools and extensions are there if you do want to access the lowest levels. Because Python has access to the same set of functions as the operating system you can use it to duplicate and extend the functionality of the operating system, whilst still retaining all of the compatibility and interface issues that we already know Python supports.
Python comes with a standard set of modules to allow you to communicate over the standard network sockets both at a basic level, and at a protocol level. If you want to read e-mail from a POP server, for example, Python already comes with the library module to enable you to do that. In addition, Python also supports XML, HTML and CGI libraries so you can parse user input and produce top-quality formatted output via a web server.
You can even compile a module for Apache, the Unix and Windows web server that embeds the Python interpreter (in a similar fashion to mod_perl). This means that when you want to execute a Python script, it does not need to be loaded separately each time, providing the maximum possible performance from your CGI scripts.
Also Zope, which provides a content management and web publishing environment, and mailman, which provides mailing list functionality, show just how far you can go with Python programs.
There are a myriad of extension modules that interface to all of the common database systems, from Oracle to Informix and free systems such as mySQL and PostgreSQL. If you don't have access to one of the free or commercial database systems, you can use Gadfly which provides a complete SQL environment written entirely in Python – no external modules or extensions are required. Because Python has strong text and data handling abilities we can use Python to interface between databases, and to act as a better summary and report tool than many of the interfaces that come with the database systems themselves. Furthermore, because Python supports a number of different systems instead of only one, we can use the same interface with any database. We can even use Tk to build the front end, and then put it on any of the supported platforms – you get an instant cross-platform, database-independent query tool!
Python can be used for anything – there are literally no limits to what the language can do. By supporting a small core set of functions, data types and abilities Python provides an excellent base on which to build. Because we can extend the functionality with C and C++ we get the best of both worlds – unlimited and unfettered expansion to do whatever we want, but in a structured and manageable format.