Python - the Programming Language Content from the guide to life, the universe and everything

Python - the Programming Language

3 Conversations

According to its own FAQ, Python is an interactive, interpreted, and object-oriented computer programming language.

Being an interpreted language, Python programs can be executed without the need for compiling the program's files into an executable file, which is required by languages like C and Java. This means a programmer can make changes to a program and observe their effects more quickly than in compiled languages. The trade-off, though, is that Python programs tend to be slower than their compiled counterparts1.

The Python interpreter is interactive, meaning programmers can enter one command at a time and they will be executed as they are entered. Programmers are able to try out ideas and see the results instantaneously. They can also interact directly with the insides of a program, making the process of finding and fixing programming errors less tedious.

Object orientation gives the programmer a powerful set of tools for building reusable software components2.

Python is known for being easy to learn, while also providing access to powerful features. It is considered a Very High Level Language, which means that for anything you want to do with it, the hard part is already done. Unfortunately, it probably works slightly differently from how you wish it would.

Why 'Python'?

Sometime early in the development of Python, its originator, Guido van Rossum, realised he was going to have to give it a name. He wanted that name to be short, unique and slightly mysterious. At the same time, he was watching a lot of Monty Python's Flying Circus re-runs. The rest is the stuff of geek-legend.

Why Use Python?

Python's rich feature set makes it easy to write complicated programs. If the features available aren't good enough, Python is designed to be extensible, so new features can be added as needed. In general, Python programs tend to be 5-10 times shorter than similar programs written in C or C++3.

The Python interpreter is available on many different platforms (Unix, Linux, Windows, Macintosh, and VMS, to name a few), making it easy to write programs without worrying about what sort of computer they will run on. Because it's interactive, programmers can design, write, and test programs efficiently.

Python is well-suited to embedding in larger, more complicated systems as a macro language. It can also be used as a glue language to connect separate, unwieldy programs, that, without the aid of Python, would not work and play well together.

Best of all, Python is absolutely free4. You can download the latest version from the Python Website at no cost, and use it for any purpose you see fit.

Since its creation in 1991, Python has become popular and widely used. It compares well with other languages for its power and flexibility, its portability, and its clarity and ease of use.

Example Code

The following is an implementation, in Python, of an efficient algorithm to print the first 50 numbers in the Fibonacci series.

class Fibonacci: def __init__(self): self.cache={} def calculate(self, n): if n < 2: return 1 try: return self.cache[n] except: return self.cache.setdefault(n, self.calculate(n-2) + self.calculate(n-1)) if __name__ == '__main__': f = Fibonacci() for i in range(50): print f.calculate(i)
1All interpreted languages share this trait, though it annoys programmers who work in interpreted languages when you point this out.2In an ideal world, programmers would never write the same code more than once. Doing so is referred to as 'reinventing the wheel'. Unfortunately, since the birth of software engineering, various wheels have been reinvented innumerable times. Though not a 'magic bullet', object-oriented programming brings the ideal closer to reality.3See 'Comparing Python to Other Languages', by Guido van Rossum.4'Free' as in speech, and 'free' as in beer, though it is copyrighted.

Bookmark on your Personal Space


Edited Entry

A699005

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry

Categorised In:


Written by

Edited by

h2g2 Editors

References

h2g2 Entries

External Links

Not Panicking Ltd is not responsible for the content of external internet sites

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more