ScripTips
Backup Your Gmail With poplib
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.
Reading a Single Line from a File With Python
Getting a line from a file is easy with Python. This tip shows you how.
Working On Files With 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.
How to Analyze A File One Line At A Time
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).
How to Analyze a File All-At-Once Using a Dictionary
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.
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'.
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.
Searching Data Faster
One of the most powerful methods of searching data is the use of a binary search tree. By halving the number of steps to an answer at each step of the search, the time gained increases with the number of items to be searched. Put concretely, a list of 1000 items can be searched in 1/10 the time of a linear search by using data structured as a binary tree.
Classes and Objects
One of the most important elements of Python programming is the use of classes . It behooves you to know well how to form classes and how to initiate objects in Python. In addition to my own discussion on the subject , this page forms a gentle introduction to the topic.
