Parent: Programming Discuss this page


"Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It offers strong support for integration with other languages and tools, comes with extensive standard libraries, and can be learned in a few days. Many Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code." Quoted at


  • An interpreted language created in the early 1990's by Guido van Rossum from the Netherlands.

  • A non profit organization called “Python Software Foundation” owns Python related intellectual property.
  • Carries a GPL-Compatible license.
  • For a nice short movie about Python click here.

The Short Live By List

  • Everything is an object: functions are no exception.

    # this is a very small do-nothing program that shows off the docstring property of a function object.
    def main():
            """This is the main function of our program. It actually does nothing
            but demonstrating that functions in python are objects which can have
            properties, this is the docstring property."""
            print "We are inside the main function\n"
    if __name__ == "__main__": # checking if were executed standalone, rather then being used as a module.
            main()             # if we were using this file as a module, then
                               # __name__ != "__main__" and main() would never
                               # get executed unless we called from within our
                               # program. 
  • Try keep code readable, yet powerful.
  • Errors should never pass silently.
  • Let's talk high level, leave the dirty work for someone else.
  • Documentation is important enough – make it part of the language objects.
  • Good practices are encouraged, not enforced.
    • Python also supports non OO programming
      • Example

        # this functions tests to see if two people are the same.
        def areWeTheSame(me,you):
                """This function tests if two people are the same. usage: areWeTheSame(MYNAME,YOURNAME)"""
                if (me,you) == ("you","me"):
                        print "We are the same person \n"
                        print "We are not the same person\n"
        def main():
  • If you toss this code example into a file and try run it using the interpreter, nothing happens. Could you guess why?

The Newbie Experience

  • Adjusting to “Everything is an object”:
    • The "simple" explanation - it's code and data packaged together, allowing one to treat that entity as a black box that “just works”.
    • import car # car is a module representing a car
      if needToDriveFast:
  • Whitespace significance : getting consistent on the spaces
    • remember this will pay off _eventually_ , as code would have a consistent style thus making code blocks more easily noticable.
  • Running code: Why doesn't my program execute?
    • Although python supports non 00p programming, there is not special "main" function that is the first entry point for executing. Therefor there's a little trick

Common Uses

  • Glue Language
    • Writing shell scripts that are more easily managable and have better readability.
  • GUI development
    • example: GTK bindings for python allow complete gui app development.
  • Web Infrastructures
    • various web and related communication mediums are python powered:
      • Mailman.
      • Plone.
      • etc
  • Nice Calculator
    • Interactive interpreter sessions allows using it as a mathmatical calculator (as well as allowing to evaluate ideas and statements on the fly)
      • example

         >>> 2+2
            >>> # This is a comment
            ... 2+2
            >>> 2+2  # and a comment on the same line as code
            >>> (50-5*6)/4
            >>> # Integer division returns the floor:
            ... 7/3
            >>> 7.0/3  # Unless there's a float involved in the operation
            >>> 7/-3
  • String processing.
  • Network Programming.
  • Operating system enhancments and interfacing.

Some Feature Highlights

  • High level language.
    • High level abstracted data types allow for rapid prototyping and
  • Facilitates code readability.
    • Identation rules makes it easier to distinguishes execution block, scope which results in less effort needed to browse the produced code.
    • Being a high level language, code is closer to natural language and thus is less cryptic compared to Perl and C.
  • Auto memory management and garbage
    • Variables and storage space just spring into existence when you first reference it.
    • There is no need to free memory of unused objects, this will happen magically.


Since the success of Ruby on Rails, frameworks also became very popular in other languages. A framework will do a lot of standard work for you, like logging, authentication, database access etc. Some popular python frameworks are:

  • Django has an MVC basis

  • Zope is mostly known as the basis for the Plone CMS

  • Pylons has a component based approach, it's easy to change to another templating engine etc.

Internal Python Community Created Articles

External links

There is a really excellent tutorial in the documentation that comes with Python:

A variety of other resources for beginners are listed on the Python wiki


Programming/Python (last edited 2008-10-16 13:23:03 by joolz)