getting-started-files/quickref.tex
author Puneeth Chaganti <punchagan@fossee.in>
Mon, 11 Oct 2010 11:40:04 +0530
changeset 285 7c4855fb8e5f
parent 217 b595f90016c5
permissions -rw-r--r--
Quickrefs

\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.