getting-started-files/quickref.tex
author anand
Mon, 15 Nov 2010 14:31:42 +0530
changeset 498 4255f995a40c
parent 285 7c4855fb8e5f
permissions -rw-r--r--
checklist not OK; one more long answer question has to be included.

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