| About InfoWorld : Advertise : Subscribe : Contact Us : Awards : Events : Store |
|
||||
|
||||
Caught in Python's grip I'M A BIG FAN of the open-source programming language called Python. In case you're wondering, Python is indeed named after the British Broadcasting Corp. comedy group Monty Python. It was created in about 1990 by Guido van Rossum, a fan of Monty Python. Since then it has matured at a phenomenal rate, thanks to its open-source nature.
Unlike Java, Python is ideal for tossing together a quick script to do mundane work. If you're a casual Linux user, you have probably executed many Python scripts and applets without knowing it. People use Python this way because it is even easier to use for mundane tasks than Unix shell script languages and infinitely more powerful. That demonstrates its breadth. I don't mean to rekindle the Python versus Java wars that raged a few years back. Both languages have their place. Neither is perfect for every need, although Python is closer to being a one-size-fits-all language than Java. But I happen to be as big a fan of Java as I am Python. I draw the comparison because you would do well to consider both Python and Java if you're about to embark on a new Web application project. You just might find that Python is more appropriate for your particular task than Java. One of the first things you'll notice about Python is its unique way of grouping statements. Python uses indentation to parse its code. Most C programmers tend to use indentation to make their code readable. You type an "if" statement, go to the next line, indent farther than the "if" statement, and then type the code that is executed if the condition is true. Although C programmers don't have to use indentation, you do it simply because it makes it easier to understand the programming logic when you come back to the code later. In contrast, if you don't indent Python statements properly your program won't run. You can use tabs, spaces, or a mix of the two, but you have to be consistent. That feels rather odd when you first start programming in Python, but it only takes a few minutes before you realize that it is not only an intuitive way to program, it pushes you to create code that is more readable, and therefore easier to maintain. The other thing you'll notice is that it is as easy to create Python classes (objects) as it is to toss together a procedural script. So much so that you often end up using objects in Python even when you don't have to. This makes your code more reusable, which is always a good thing. I've barely scratched the surface of what Python is and what it can do. If I've piqued your interest, visit www.python.org for more information. Once you learn your way around Python and are ready to start programming I recommend you pick up Programming Python by Mark Lutz, from the O'Reilly series, now in its 2nd Edition.Next week I'll discuss options available for server-side Web applications programming with Python. Nicholas Petreley is the founding editor of VarLinux.org ( www.varlinux.org ) and LinuxWorld. Reach him at nicholas@petreley.com. RELATED SUBJECTS Discuss this article in our online forums MORE > SPONSORED WHITE PAPERS
SPONSORED LINKS
|
|||||||||||||||||||||||||||||||||||||||||
|
||||||||||