getting-started-files/quickref.tex
author Puneeth Chaganti <punchagan@gmail.com>
Wed, 27 Oct 2010 12:54:41 +0530 (2010-10-27)
changeset 358 284170f2c12e
parent 285 7c4855fb8e5f
permissions -rw-r--r--
Merged Heads.
\textbf{Getting Started -- files}

\lstinline|f = open('filename')| returns a file object. \lstinline|f|
can be used to perform further operations on the file. 

\lstinline|f.read()| reads the whole file and returns the contents. 

\lstinline|f.close()| closes the file. 

\lstinline|for line in open('filename'):| -- iterate over the file
line-by-line.