What is Python?
Hi folks, today I'm going to introduce you a rather unknown language called Python.
This is not a tutorial for Python, it's just a small article to explain what is Python (hence the title!) and how cool it is to write Python programs. Yes, you can call that stupid advocacy but stay with us because you'll love Python! :))
In one line, Python could be described as a general-purpose, object oriented, dynamic and high level interpreted language. Python is not only a text manipulation language, it's a real general-purpose interpreted programming language.
In its philosophy, Python is a mix between C++, SmallTalk, Lisp, Perl and maybe a bit of Unix shell! I know it might sounds frightening but, as crazy as it seems, the syntax is extremely digestible! =)
For the story so far, Python has been initialy designed and implemented by Guido Van Rossum in the early 90ies. The Python interpreter has been ported to a wide spread of Unix flavors, Macintosh and to Win32. A well written Python module should be portable on all the platforms supporting the Python unless you really use Unix or Win32 specific modules for some system level tasks. A Java interpreter (JPython) is available and allows you to run Python on almost every computing appliance running a Java Virtual Machine! And it is said that the overall performance are a lot better that one would expect... I must admit that I didn't tested it but I may have to do so
It's possible to compile Python into some bytecode modules that runs much faster.
It's very easy to learn Python since, unlike Perl (which is a write-only language), the language only uses a minimal set of statements and built-in functions. And if you already played around with some weirdos' programming languages like Lisp or Prolog, you'll just love the way Python handles lists!
In Python, everything is an object (except these goddamn'd built-in types like int or float). It means that a class is an object (yes!), a method is an object, a function is an object, etc. I told you it was dynamic!
Python is a dynamic language, you do not have to declare any variable you use, there are strict rules that defines the scope of a declaration.
Python also supports operator overloading but in an easier way than C++ does thanks to a very clear syntax.
Python has powerful built-in types like lists, dictionaries (associative arrays), sequences and tuples.
Some modules available in the standard library:
- string, advanced operation on string objects
- cgi, handles CGI data input
- re, support for PERL alike regular expressions
- math/cmath, advanced functions for real and complex numbers
- imageop, image processing
- color, color conversion (RGB,HSV,...)
- audiop, audio streams processing
- and many more : SGML/HTML/XML parsers, Unix specific tools, etc
And some other famous modules like MySQLdb which provides a finger-in-the-nose access to any MySQL relational database server.
It's possible to write Python modules in C or C++ as much as to embed Python modules into your C or C++ applications. This makes Python a real "glue" language between several C or C++ applications. And if you don't want to learn the Python/C API, you can use the Simple Wrapper Interface Generator which will do all the dirty job for you!
If you have to build a GUI, software bindings for both Tk and Gtk are also available.
A Python program is maintainable and readable by someone who hasn't written it which is not the case of some popular scripting languages... who the heck said "Perl"?!? =)
Now you might wonder why the hell am I talking about an interpreted language that nobody will use to code demos. Just because Python is an excellent and powerful scripting language that is very suitable to perform some tasks for you in the scope of demo-making! Here are a few area where Python scripts could be used:
- to compute look-up tables or convert files
- to prototype some parts of you programs without having to mind about any data structure or standard algorithm availability concerns.
- as a plug-in to your demo to perform some boring tasks like text scanning and parsing or to be able to customize some features without having to rebuild the whole code.
- to write CGI scripts to empower your group's website
- and so much more!
I learned Python in one single week-end, I just read Guido's tutorial and started to code some search engine for our website! I can assure you that once you know Python, it will be your favorite language to develop any small program you need that would take a couple of days to write in C but with Python, it will be coded within the afternoon!
There is an excellent tutorial written by Mister Guido Van Rossum himself, available at the world headquarters of all Python fans. There is also another very good tutorial.
I hope to propose some Python programming article in the 20th issue of your favorite diskmag: HHuuuugggiiiiiiii!
Just let me know which subject would you like to see: CGI, text parsing, network programming,...
brioche of the aspirine intercontinental d-zign maffia
PS: The word 'Python' appears only 37 times in this document (including the occurence in this line.)