BBC Home

Explore the BBC

h2g2
9th December 2009
Accessibility help
Text only

Guide ID: A699005 (Edited)

Edited Guide Entry


SEARCH h2g2
Edited Entries only
Search h2g2Advanced Search


New visitors: Create your membership
Returning members: Sign in
BBC Homepage
The Guide to Life, The Universe and Everything.

3. Everything / Languages & Linguistics / Languages / Computer Languages
3. Everything / Maths, Science & Technology / Computers / Computer Languages and Programming

Created: 7th March 2002
Python - the Programming Language
Contact Us


Like this page?
Send it to a friend!

 

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)

1 All interpreted languages share this trait, though it annoys programmers who work in interpreted languages when you point this out.
2 In 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.
3 See 'Comparing Python to Other Languages', by Guido van Rossum.
4 'Free' as in speech, and 'free' as in beer, though it is copyrighted.


Clip/Bookmark this page
This article has not been bookmarked.
ENTRY DATA
Written and Researched by:

Niten

Edited by:

beeline

Referenced Entries:

Java - the Programming Language
Object-oriented Programming
C - the Programming Language
Fibonacci Series

Related BBC Pages:

Monty Python's Flying Cir...

Referenced Sites:

Python FAQ
'Comparing Python to Othe...
Python Website

Please note that the BBC is not responsible for the content of any external sites listed.


CONVERSATION TOPICS FOR THIS ENTRY:

Start a new conversation

People have been talking about this Guide Entry. Here are the most recent Conversations:

TITLE
LATEST POST
Complementary to C/C++ and Java tooJan 27, 2003
OOPJul 10, 2002
Questions about "Python"!Mar 8, 2002




Disclaimer

Most of the content on h2g2 is created by h2g2's Researchers, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the BBC. The BBC is not responsible for the content of any external sites referenced. In the event that you consider anything on this page to be in breach of the site's House Rules, please click here. For any other comments, please start a Conversation above.




About the BBC | Help | Terms of Use | Privacy & Cookies Policy