[portland] Not Seeing Script Error(s)

Ethan Furman ethan at stoneleaf.us
Tue Nov 22 22:53:25 CET 2011


Rich Shepard wrote:
> On Tue, 22 Nov 2011, Ethan Furman wrote:
> 
>> reader = csv.reader(open("test.txt","r"),
>>                    delimiter="|",
>>                    quotechar="'")
>> output = csv.writer(open("out.txt","w"),
>>                    delimiter="|",
>>                    quotechar="'")
> 
> Ethan,
> 
>   How are these opened files closed? csv.reader() and csv.writer() have no
> close method.
> 
> Rich


They are closed automatically.  It's not good practice to do this way, 
though -- better would be to assign the open files to their own name, 
then you could 'name.close()' when you were done.

~Ethan~


More information about the Portland mailing list