六月 28, 2008

Diigo Diary 06/28/2008

The str() function is meant to return representations of
values which are fairly human-readable, while repr() is
meant to generate representations which can be read by the interpreter
(or will force a SyntaxError if there is not equivalent
syntax).

open() returns a file
object, and is most commonly used with two arguments:
“open(filename, mode)“.

mode can be 'r' when
the file will only be read, 'w' for only writing (an existing
file with the same name will be erased), and 'a' opens the file
for appending; any data written to the file is automatically added to
the end. 'r+' opens the file for both reading and writing.
The mode argument is optional; 'r' will be assumed if
it’s omitted.

Python provides a standard module calledpickle. This is an
amazing module that can take almost
any Python object (even some forms of Python code!), and convert it to
a string representation; this process is called pickling.