Python 101 (part 1): Snake Eyes - The Jedi Master Speaks (
Page 2 of 6 )
Some of Python's most powerful features include:
Object-oriented framework: Built from the ground up as an object-oriented language,
Python provides built-in constructs that make it simple for developers to structure
code for maximum reusability. Python's "dynamic typing", which automatically recognizes
objects like numbers, strings and lists, and negates the need to declare variable
types and sizes, offers an advantage not found in languages like C or Java, while
automatic memory allocation and management, together with a vast array of pluggable
libraries and high-level abstractions, complete the picture.
Extensibility: Python makes it easy to add new capabilities to your code, by
importing specialized libraries into your program. A large number of pre-built
libraries ship with the standard Python distribution, and more are available free
of charge on the Web. Additionally, Python also allows you to compile new "extension
modules" for additional functionality, or to improve performance.
Portability: Python distributions are available for a wide variety of operating
systems, including Windows, Macintosh, Amiga and most flavours of UNIX, including
Linux. This portability ensures that code written on one platform will work on
others with zero or minimal changes required. In case a distribution isn't available
for a specific platform, you can even download the source code and compile it
yourself!
Readability: Python's clear and elegant syntax, and emphasis on proper indentation
of code blocks, improves code readability, making it easier to understand code
a year later. By imposing lexical and syntactical rules on language constructs,
Python reduces the time spent on understanding (and developing) application logic,
and also makes program code easier to maintain over time.
Performance: There's an interesting piece of trivia geeks should be aware of
here. Python is an odd hybrid of compiled and interpreted languages: the code
you write is first converted to so-called "bytecode" and then executed by the
Python interpreter. Since executing bytecode is faster than interpreting statements
line-by-line, Python offers a substantial performance advantage of other interpreted
languages. It should be noted, however, that the conversion to bytecode is handled
internally by Python, and is not visible to the end user.
Open licensing model: Like Perl and PHP, Python is available for free, to anyone
who wants it, over the Internet, in both source and binary form. Users may use
and distribute it without restriction, and even charge a fee for it if they so
desire.
Programmers love to debate the virtues of different programming languages, and
it's no different here. However, Python comes off favourably in most of these
comparisons. You can find detailed evaluations of Python versus other programming
languages at
http://www.python.org/doc/Comparisons.html. And you might want to take a minute to enjoy this nugget culled from the Python
humour pages at
http://www.python.org/doc/Humor.html
EXTERIOR: DAGOBAH -- DAY
With Yoda strapped to his back, Luke climbs up one of the many thick vines that
grow in the swamp until he reaches the Dagobah statistics lab. Panting heavily,
he continues his exercises -- grepping, installing new packages, logging in as
root, and writing replacements for two-year-old shell scripts in Python.
YODA: Code! Yes. A programmer's strength flows from code maintainability. But
beware of Perl. Terse syntax...more than one way to do it...default variables.
The dark side of code maintainability are they. Easily they flow, quick to join
you when code you write. If once you start down the dark path, forever will it
dominate your destiny, consume you it will.
LUKE: Is Perl better than Python?
YODA: No... no... no. Quicker, easier, more seductive.
LUKE: But how will I know why Python is better than Perl?
YODA: You will know. When your code you try to read six months from now.