1. Home
  2. Computing & Technology
  3. Python

Python: Most Popular Articles

These articles are the most popular over the last month.
"Hello, World!"
The purpose of this Hello World tutorial is to take a simple program and build upon it to illustrate the various elements of the Python language.
String Methods - 1 of 2
Python's built-in string methods are incredibly powerful. As the name implies, each of the following methods are available through class String. Every string object is an instance of that class and has these methods available. This is the first of a two-part reference on Python's built-in string methods.
A Simple Python Web Server
Web servers are an invaluable part of the Internet. But sometimes Apache is over the top for a web service solution. Sometimes all you need is a little program to deliver data upon request. Here is how to build one with Python's socket module.
Line-By-Line File Analysis
This tip gives advice on analyzing a file one line at a time. This type of analysis is particularly useful when writing a program that will be run several times simultaneously (e.g., CGI scripts).
What is Python?
Programming is an object-oriented interpreted language.
Python Exceptions
This tutorial is part of a series designed to help you learn to program in Python. This tutorial looks specifically at the exceptions, errors, and warnings within Python while using try and except. This step looks at raising multiple try-except statements.
Python Text Editors
Before you can start programming in Python, you must ensure you have the right equipment. In addition to having Python installed, you will need a text editor. Here I offer some suggestions on choosing one that you will meet your needs.
A Python Web Client
The first step in programming toward the Internet is to tell Python to create a socket object. Here is how to do it.
Python CGI
This tutorial discusses how to use Python to receive and process data from the Common Gateway Interface (CGI). It assumes that you are familiar with CGI basics. If you are not, you should first work through the material at [link url=http://webdesign.about.com/od/cgi/index.htm]About.com's Webdesign site[/link].
Python 2.5's 'with' Statement
One of the new features that was released with Python 2.5 last month is the 'with' statement. For those of you who are used to Python's try...except statement, you may find this to be the biggest boon of upgrading.
Regular Expressions Primer
This primer offers a concise discussion of the regular expression syntax used in Python. If you need a reference, this will be helpful. If you are unsure what to do with regular expressions, you may benefit from the Python tutorial.
Python Tutorials for Beginners
This series of tutorials is intended to help anyone learn to program in Python. If you are new to computers, however, you may benefit from the absolute beginner's tutorial: How a Computer Looks at Your Program.
Python Game Programming
If you simply cannot wait for About.com's tutorial on developing games in Python, you might try one of these tutorials. They cover the development of simple geometric games through to more complicated, arcade-style games.
Forming RegEx
Every successful Python programmer understands Python's regular expression (regex) system and how to formulate regular expressions for matching. Understanding regex is key to Python programming. How do you match some but not all of a list? Use Python's regular expressions to your advantage.
Python and PostgreSQL
In this tutorial, we will program Python to insert data into a PostgreSQL database. Here we see how to commit Python data into a PostgreSQL database using psycopg.
Beginning Python
This beginning tutorial is part of a series for learning the fundamentals of Python. It covers the data types used in Python. Here we look at how to work with variables in Python.
Python Decorators
The built-in Python function classmethod() was a pre-cursor to Python's decorators.
RSS Reader in Python
An RSS Reader is a straightforward program, and building one ensures that one knows the basics of the language. It also teaches the basics of Python web programming and XML handling. Follow these step-by-step tutorials to build a web-based, customisable RSS Reader.
Beginning Python: Syntax
This tutorial is part of a series on the fundamentals of Python. It covers the syntax used in Python programming. If you are new to Python, this tutorial is for you. If you are completely new to programming but have been using a computer for a little while, you should do fine with these tutorials. If you are completely new to computers, you may want to read through the tutorial [link url=throughacomputerseye]"How A Computer Looks at Your Program"[/link].
HTML Forms with Python
This tutorial discusses how to use Python and CGI to create plain HTML pages and HTML forms.
An Introduction to wxPython
Only so much can happen at the command line. Most every modern application has a graphic user interface (GUI). For Python, wxPython is the most mature, cross-platform graphic interface available. This introduction shows how to say "Hello, World!" with a GUI.
Python's Exceptions
Python's built-in exceptions are many; knowing them really helps your programming.
Python Encodings
Python can also encode ASCII text as Unicode, not merely Unicode as ASCII.
Create A Calendar In Python
Whether you want to develop a web-based diary or just want a calendar for your website, a dynamically created calendar in HTML is a very useful item to have. Creating one is a snap with Python's calendar module.
Running a Python Program
Programming is pointless if you cannot run, or execute, the program you write. Executing a Python program tells the Python interpreter to convert the Python program into something the computer can read and act upon. There are two ways to do this: using a Python shell and calling the Python interpreter with a "bang" line. The how-to's of both are addressed here.
Getting a Line With Python
Getting a line from a file is easy with Python. This tip shows you how.
An FTP Client in Python
FTP is a critical protocol for a host of networking solutions. Here is how to use Python's ftplib module to interact with FTP servers over an open connection.
Self-Documenting Code
Python has built-in documentation features. Here is how to write self-documenting functions.
Testing CGI
It is hard to program CGI when you do not know your environment. Here is how to use os.environ to learn about the CGI world of your script.
Working With Files in Python
When computers are not reading code, they are processing data from or to files. These tips show you how to do some common tasks related to file input and output using Python.
Python's os Module
Python's os module provides a convenient interface for many system-level operations. This overview of the module shows how to interact dynamically with the operating system and runtime environment of the Python interpreter.
MySQL Insertion
Define a class with a method for inserting the data.
set and frozenset
Python's built-in set types are helpful ways to create both mutable and immutable sets of values for use in your programming. Here are the functions and methods that you can use with each.
String Formatting Operations
Python's string formatting operations are important to know for most any program that you write. Here is a comprehensive guide to them.
The socket Module - Pt1
Python's socket module is the foundational module for all network programming in Python. Here is a reference of the functions, classes, and constants available through it.
Accessing MySQL with Python
Python comes with "batteries included", as the saying goes. This reference to the Python library also suggests the secret to Python programming in general. It is also the basis for any database management you want to do. Python modules exist for every major database format. Here we look at the more common ones.
The socket Module - Pt3
Python's socket module is the foundational module for all network programming in Python. Here is a reference of the functions, classes, and constants available through it.
How a Computer Reads
Are you clueless about what a computer actually does with a program? If so, this tutorial is for you. It will tell you the basic parts of a program's composition and how the computer "sees" them.
Comparison Operations
Python's comparison operations are pretty straightforward. Here is a reference to them with a bit of detail that you may not know.
Pt 1: Laying the Groundwork
first step in any software project is understanding the problem and then laying the groundwork. Here we consider the tasks of an RSS Reader and lay the groundwork in HTML, CGI, and PHP.
notation
Lambda calculus can be used to design just about any kind of function you might need. Here is how to use it in lieu of pseudo-code to describe your functions quickly.
RegEx Examples: Inequality
Python's regular expression (regex) engine is very powerful. This page discusses square braces or brackets.
Bit String Operations
Python's bit string operations are an important part of advanced programming. Here you will find a reference to the bit-wise operators in Python.
Checking URLs With Python
In the Wild World of the Web, checking the DNS entry of a URL or IP address is increasingly necessary. Here is how to do it with the Python socket module
Review of Beginning Python
My review of "Beginning Python"
Pickle Objects With Python
Python's pickle module is a quick and easy way to save Python objects in a standard format. Here is how to save and restore Python objects with pickle.
RSSReader.py
Python Code for an RSS Reader
Shelve-ing Python Objects
Python's shelve module is a powerful way to include persistence and to save objects in an easy-access database format. Here is how to open, assign value to, restore value from, and close shelve dictionaries and databases.
Pt 2: The Feed Address
Here we build an RSS Reader in Python, using the Python modules sys, string, urllib2, and xml (both dom and minidom).
RSS Reader Code
This page links to the source code for the tutorial series on building an RSS Reader with Python.
Types of Peer-to-Peer Networks
Peer-to-peer networks vary little in their dynamics from other networks. Here is an overview of where the differences lie.
Using PHP-Javascript for CGI
Javascript watches user actions and behavior and initiates actions accordingly. Here we submit a form without the usual 'Submit' button.
Boolean Operations
Boolean operators are a significant part of Python programming. Here is a reference on how to use them.
Python's String Templates
Python's string module provides a Template class to process strings powerfully and en masse. Here is a description of the methods and the single attribute of this class and an example of how to use template string objects.
What is a Regular Expression?
Regular expressions are a Python programmer's best friend. Understanding what they are and how to use them will help you leap tall programming tasks in a single bound.
Beginning Python: Operators
This tutorial is part of a series designed to help you learn to program in Python. This tutorial looks specifically at the operators within Python.
Get Login Info With getpass
Accepting login information in plain text is inherently dangerous from the persepctive of computer security. Fortunately, Python has the getpass module which allows the handling of login information without leaving a trace in a system's cache.
Pt 3: Finishing the Program
The first step in any software project is understanding the problem and then laying the groundwork. Here we build a Python program that fetches RSS feeds and presents them in HTML via CGI or via PHP and Javascript
Text vs Data in Python 3.0
The difference between text and data is critical for programming in Python 3.0. One of the key areas impacted by this is converting between str and bytes.
Pythons 're' Module
Python's re module is without a doubt one of the most commonly used parts of the Python library. Remember its functions, on the other hand, is not always easy. Here is a reference to help you keep it all straight.
Analyze A File All-At-Once
This tip gives advice on analyzing one or more files simultaneously using Python's dictionary data types. This type of analysis is useful for local analysis (as opposed to network server usage) when parts of one or more files need to be consulted simultaneously and in rapid succession.
Programming Securely
Programming for security is an imperative for the web programmer. But it does not necessitate a siege mentality. As discussed here, secure programming is smarter programming that includes securing against cross site scripting (XSS).
String Module Functions
Python's string module provides a couple of functions that are not available through string methods. Here they are with brief descriptions of each for your reference.
Python's File Descriptors
Python's os module handles much of the language's portability with respect to the local operating system. Here is how to do cross-platform system programming with Python.
The Shell vs The File
In Python, there are two ways to create a program: the Python shell and the text file. This article offers a brief overview of each and discusses their advantages and disadvantages.
Python String Constants
Python's string module provides many helpful constants that you can use in your programming. Here is each of the constants and a brief description of each.
"Hello, World" in Tkinter
Most every modern application has a graphic user interface (GUI). For Python, Tkinter is the most commonly available graphic interface toolkit simply because it comes with every installation of Python. This introduction shows how to say "Hello, World!" with Tkinter.
Numeric Types and Operations
Python recognises several types of numbers. Here is a reference for the numeric types that Python knows and what you can do with them.
Python's Protocol Modules
While most programming is done with local resources in mind (i.e., your computer), Python is more than able to pull data from the furthest reaches of the globe for whatever purpose you deem necessary. It does this via network protocols. A protocol is simply a set format for exchanging information. These pages address how your Python program can communicate over a network using protocols such as SOAP and TCP/IP as well as platforms such as Zope and Plone.
Python Regex: the Colon
Python's regular expression (regex) engine is very powerful. This page discusses the use of the colon.
Python Regex: Regex Negation
Python's regular expression (regex) engine is very powerful. This page discusses regex negation.
Regular Expression Objects
Python's re module is without a doubt one of the most commonly used parts of the Python library. Here is a reference of the methods and attributes available in each regex object
Python Regex: Characters
Python's regular expression (regex) engine is very powerful. This page discusses special characters.
Deprecated String Functions
Python's string module offers a bevy of functionality. Some of it, however, has been moved to the built-in string methods. Here are the functions that are deprecated.
XRange Type
Python's xrange() function is a very easy way to generate a range without consuming a lot of resources. Here is a reference to how it is used and what operations it supports.
Sequence Types
Python supports several kinds of sequences. Here is a guide to each.
Port Scanning
Port scanning is a valuable facility for network programming as well as security testing for your network. Here is how to build a port scanner in Python.
RegEx Examples: *?
Python's regular expression (regex) engine is very powerful. This page discusses the compound regex: '*?.'
Backup Your Gmail
Getting your Google mail through POP3 is easy with Python's poplib library. Here is how to use getpass and poplib to script your Gmail retrieval and to make a local backup of your mailbox.
Pt 2: The Feed Address
The first step in any software project is understanding the problem and then laying the groundwork. Here we consider the tasks of an RSS Reader and lay the groundwork in HTML, CGI, and PHP.
Iterators
Python's iterators are very powerful and helpful. Here is a guide to the iterator protocol used in Python.
RSSReader.php
The PHP Layer for an RSS Reader
Python Regex: Curly Braces
Python's regular expression (regex) engine is very powerful. This page discusses curly braces.
Python Regex: Parentheses
Python's regular expression (regex) engine is very powerful. This page discusses the use of parentheses.
Transitioning from 2.x to 3.0
With the release of Python 3.0, the number of projects that are built on a 3.x interpreter and that break compatibility with the 2.x series and before will only increase. The points of incompatiblity vary in importance, but your 2.x coding style is almost guaranteed to be incompatible on some level. Here is a guide to how dictionaries have changed in Python 3.0.
Shell
Define the "shell"
Using poplib
Whether you are coding for the Web, the desktop, or for handheld communication devices (PDAs, smartphones, etc.), being able to collect email is an important part of network programming. Here is how to use the poplib module to access a remote POP3 mailbox.
The Python Library
This page offers an overview of the most commonly used modules from the Python Standard Library. It is not intended as a replacement for the documentation. Rather, it highlights modules which factor into most general purpose programming projects.
RegEx Examples: \S
Python's regular expression (regex) engine is very powerful. This page discusses square braces or brackets.
feedlist.dat
The Data File for an RSS Reader in Python
Moving Around in a File
If you are familiar with reading a file into memory but still wonder how to move around inside it after that, this ScripTip will help you. Using the code from the earlier tip, this discussion shows how to access all or one record of the dictionary 'record'.
Secure Python Programming
All but the simplest programs operate in a web-enabled environment. Navigating the (in)security of such an environment is notoriously difficult. This article looks briefly at the state of network security and what it means for Python programmers.
The socket Module - Pt2
Python's socket module is the foundational module for all network programming in Python. Here is a reference of the functions, classes, and constants available through it.
RegEx Examples: Curly Braces 3
Python's regular expression (regex) engine is very powerful. This page discusses the use of curly braces with question marks.
Get POP3 Email with poplib
Getting your mail through POP3 is easy with Python's poplib library. Here is how to use getpass and poplib to script your mail retrieval and to make a local backup of your mailbox.
Python Regex: the Pipe
Python's regular expression (regex) engine is very powerful. This page discusses the pipe.
Explore Python
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.