75% developed

Python Programming/Overview

From Wikibooks, open books for an open world
Jump to navigation Jump to search


  Index Next: Getting Python

Python is a high-level, structured, open-source programming language that can be used for a wide variety of programming tasks. Python was created by Guido Van Rossum in the early 1990s; its following has grown steadily and interest has increased markedly in the last few years or so. It is named after Monty Python's Flying Circus comedy program.

Python is used extensively for system administration (many vital components of Linux distributions are written in it); also, it is a great language to teach programming to novices. NASA has used Python for its software systems and has adopted it as the standard scripting language for its Integrated Planning System. Python is also extensively used by Google to implement many components of its Web Crawler and Search Engine & Yahoo! for managing its discussion groups.

Python within itself is an interpreted programming language that is automatically compiled into bytecode before execution (the bytecode is then normally saved to disk, just as automatically, so that compilation need not happen again until and unless the source gets changed). It is also a dynamically typed language that includes (but does not require one to use) object-oriented features and constructs.

The most unusual aspect of Python is that whitespace is significant; instead of block delimiters (braces → "{}" in the C family of languages), indentation is used to indicate where blocks begin and end.

For example, the following Python code can be interactively typed at an interpreter prompt, display the famous "Hello World!" on the user screen:

 >>> print "Hello World!"
Hello World!

Another great feature of Python is its availability for all platforms. Python can run on Microsoft Windows, Macintosh and all Linux distributions with ease. This makes the programs very portable, as any program written for one platform can easily be used on another.

Python provides a powerful assortment of built-in types (e.g., lists, dictionaries and strings), a number of built-in functions, and a few constructs, mostly statements. For example, loop constructs that can iterate over items in a collection instead of being limited to a simple range of integer values. Python also comes with a powerful standard library, which includes hundreds of modules to provide routines for a wide variety of services including regular expressions and TCP/IP sessions.

Python is used and supported by a large Python Community that exists on the Internet. The mailing lists and news groups like the tutor list actively support and help new python programmers. While they discourage doing homework for you, they are quite helpful and are populated by the authors of many of the Python textbooks currently available on the market.

This book describes Python, an open-source general-purpose interpreted programming language available for the most popular operating systems. The current versions are 3.x while versions 2.x are no longer supported, since 2020. This book describes primarily the versions 3.x, but does at times reference versions 2.x.

There are a few implementations for Python 3 (and older): the standard implementation written in C, and PyPy, a JIT-compiled version written in RPython - a subset of Python. For Python 2 only there are Jython written in Java and IronPython written in C# for the .NET environment.

Contents

Intro

Overview 75% developed  as of Aug 6, 2006
Getting Python 75% developed  as of Aug 6, 2006
Development Environments25% developed  as of Feb 13, 2007
Interactive mode 75% developed  as of Aug 6, 2006
Self Help 25% developed  as of Dec 15, 2008

Basics

Creating Python programs 75% developed  as of Aug 6, 2006
Variables and Strings 100% developed  as of Aug 7, 2007
Basic syntax 75% developed  as of Aug 6, 2006
Sequences 75% developed  as of Aug 10, 2010 (Strings, Lists, Tuples, Dictionaries, Sets)
Data types 75% developed  as of Aug 6, 2006
Numbers 75% developed  as of Aug 6, 2006
Strings 75% developed  as of Aug 6, 2006
Lists 75% developed  as of Aug 6, 2006
Tuples 75% developed  as of Aug 6, 2006
Dictionaries 75% developed  as of Aug 6, 2006
Sets 75% developed  as of Aug 6, 2006
Basic Math 50% developed  as of Mar 19, 2007 -- redundant to "Operators"
Operators 75% developed  as of Aug 6, 2006
Control Flow 75% developed  as of Aug 6, 2006
Decision Control 100% developed  as of Dec 1, 2008
Conditional Statements 100% developed  as of Dec 1, 2008
Loops 50% developed  as of Mar 27, 2009
Functions 75% developed  as of Aug 6, 2006
Scoping 25% developed  as of Aug 6, 2006
Input and Output 75% developed  as of Aug 6, 2006
Files 50% developed  as of Aug 6, 2006
Modules 75% developed  as of Aug 6, 2006
Classes 75% developed  as of Aug 6, 2006
Exceptions 75% developed  as of Aug 6, 2006
Errors 25% developed  as of Jul, 2008
Source Documentation and Comments 25% developed  as of Mar 2, 2009
Idioms 0% developed  as of Apr 11, 2014
Package management
Python 2 vs. Python 3

Advanced

Decorators 25% developed  as of Dec 16, 2008
Context Managers 50% developed  as of April 10, 2014
Reflection 25% developed  as of April 10, 2014
Metaclasses 75% developed  as of Aug 6, 2006
Performance
PyPy
Cython
Command-line one-liners
Tips and Tricks 25% developed  as of Aug 6, 2006

Modules

Standard library modules

Standard Library 0% developed  as of Feb 10, 2009
Regular Expression 75% developed  as of Aug 6, 2006
External commands
XML Tools 25% developed  as of Aug 9, 2010
Email 25% developed  as of Feb 21, 2009
Threading 25% developed  as of Aug 6, 2006
Sockets 25% developed  as of Aug 9, 2010
GUI Programming 50% developed  as of Aug 9, 2010
Tkinter
CGI interface 50% developed  as of Aug 15, 2014
WSGI web programming 0% developed  as of Aug 6, 2006
Internet 75% developed  as of Feb 10, 2009
Networks 0% developed  as of Aug 6, 2006
Math

Third-party modules

Databases -- to be merged with the following chapter
Database Programming 25% developed  as of Aug 9, 2010
numpy
Game Programming in Python 25% developed  as of Aug 6, 2006
Qt4 75% developed  as of Feb 10, 2009
Dbus 0% developed  as of Jan 25, 2009
pyFormex
matplotlib
Sorted Container Types
Excel
MS Word

Writing extension modules

Extending with C 50% developed  as of Aug 6, 2006
Extending with C++ 25% developed  as of Aug 6, 2006
Extending with Pyrex 0% developed  as of Aug 9, 2010
Extending with ctypes 25% developed  as of Aug 9, 2010
Extending with Perl 25% developed  as of Aug 9, 2010

Appendices

Popularity
Links
Authors
Library Modules
Naming conventions

See also



Please add {{alphabetical}} only to book title pages.


  Index Next: Getting Python