Python
All tutorials in Python
Sort By:    Name   Rating   Views  Comments    Date 
Browse Pages :    1  2  3  >  >> 

Floating-point numbers are represented in computer hardware as base 2 (binary) fractions. For example, the decimal fraction.

Views: 148 Comments: 0

Some versions of the Python interpreter support editing of the current input line and history substitution, similar to facilities found in the Korn shell and the GNU Bash shell. This is implemented using the GNU Readline library, which supports Emacs-style and vi-style editing.

Views: 111 Comments: 0

This second tour covers more advanced modules that support professional programming needs. These modules rarely occur in small scripts.

Views: 150 Comments: 0
Brief Tour of the Standard Library
Submitted 05 June 2008

Be sure to use the "import os" style instead of "from os import *". This will keep os.open() from shadowing the builtin open() function which operates much differently. The builtin dir() and help() functions are useful as interactive aids for working with large modules like os:

Views: 94 Comments: 0
Classes
Submitted 05 June 2008

Python's class mechanism adds classes to the language with a minimum of new syntax and semantics. It is a mixture of the class mechanisms found in C++ and Modula-3. As is true for modules, classes in Python do not put an absolute barrier between definition and user, but rather rely on the politeness of the user not to ``break into the definition.''

Views: 88 Comments: 0
Errors and Exceptions
Submitted 05 June 2008

Until now error messages haven't been more than mentioned, but if you have tried out the examples you have probably seen some. There are (at least) two distinguishable kinds of errors: syntax errors and exceptions.

Views: 229 Comments: 0
Input and Output
Submitted 05 June 2008

There are several ways to present the output of a program; data can be printed in a human-readable form, or written to a file for future use. This chapter will discuss some of the possibilities.

Views: 103 Comments: 0
Modules
Submitted 05 June 2008

If you quit from the Python interpreter and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if you want to write a somewhat longer program, you are better off using a text editor to prepare the input for the interpreter and running it with that file as input instead. This is known as creating a script.

Views: 84 Comments: 0
Data Structures
Submitted 05 June 2008

This chapter describes some things you've learned about already in more detail, and adds some new things as well.

Views: 111 Comments: 0
More Control Flow Tools
Submitted 05 June 2008

Besides the while statement just introduced, Python knows the usual control flow statements known from other languages, with some twists.

Views: 90 Comments: 0
An Informal Introduction to Python
Submitted 05 June 2008

In the following examples, input and output are distinguished by the presence or absence of prompts (">>> " and "... "): to repeat the example, you must type everything after the prompt, when the prompt appears; lines that do not begin with a prompt are output from the interpreter.

Views: 96 Comments: 0
Using the Python Interpreter
Submitted 05 June 2008

The Python interpreter is usually installed as /usr/local/bin/python on those machines where it is available; putting /usr/local/bin in your Unix shell's search path makes it possible to start it by typing the command.

Views: 138 Comments: 0
Whetting Your Appetite
Submitted 05 June 2008

If you do much work on computers, eventually you find that there's some task you'd like to automate. For example, you may wish to perform a search-and-replace over a large number of text files, or rename and rearrange a bunch of photo files in a complicated way.

Views: 94 Comments: 0
A peck of pickled Python
Submitted 02 June 2008

Python pickling support comes from the pickle module, and its cousin, the cPickle module. The latter was coded in C to provide better performance and is the recommended choice for most applications. We'll continue to talk about pickle, but our examples will actually make use of cPickle. Since most of our examples will be shown from the Python shell, let's start by showing how to import cPickle...

Views: 179 Comments: 0
Schema evolution Python
Submitted 02 June 2008

Over time you'll find yourself having to make changes to your class definitions. If you've already pickled instances of a class that needs changing, you'll likely want to retrieve and update those instances so that they continue to function properly with the new class definition. We already saw some of the errors that can occur when changes are made to classes or modules. Fortunately, the pickling...

Views: 102 Comments: 0
Browse Pages :    1  2  3  >  >>