[Help] Closing files

Martin Skøtt mskott at image.dk
Sat Aug 5 16:19:42 EDT 2000


Oliver Hofmann <a2619725 at uni-koeln.de> writes:

> Greetings everyone,
> currently fiddling with a python script and running into some problems.
> It _seems_ as if Python does not close a file properly, but I am quite sure
> the problem is somewhere within my code.
> 
> Here's a snippet of the relevant code:
> 
> ---8<----
> text = string.join(unique, " ")
> 
> file = open("/home/setar/scripts/tmp_output", "w")
> file.write(text)
> file.close

I am no guru, but I think what you are missing is the () when you are
calling the close method of your file object, like this:
        file.close()

-- 
Many regards
Martin Skøtt
mskott at image.dk

Believe nothing no matter where you read it or who has said it, not even if I
have said it, unless it agrees with your own reason and your own common sense. 
--Buddha



More information about the Python-list mailing list