[Tutor] file(), open()

Alan Gilfoy agilfoy at frontiernet.net
Sat May 26 14:30:25 CEST 2007


I want to work with simple ASCII text files, here..

I know you get them loaded into Python with file() or open()

The arguments for file() and open() are: (filename, mode, buffering).
How do you refer to the filename? Do you put it in quotes? Do you put  
in the file's full directory path? Or do file() and open() refer to  
the same directory as the one the script is in?
Are the mode and buffering things always necessary arguments?

For now, I just want to read/manipulate files, not write to them.

What do file() and open() create? Do you need to set them equal to  
some variable? Is one better than the other?

I want to create a list, where each list item is a line in the file.  
(The, my program would do stuff with the list.)







More information about the Tutor mailing list