[Tutor] How to close a file opened with csv.write
Gerrit Holl
gerrit at nl.linux.org
Fri Jan 30 11:38:43 EST 2004
Michel B=E9langer wrote:
> how do I close a file that has been opened by csv.writer (with the=20
> command below)? or how do you released the file from IDLE because it=20
> cannot be deleted or moved until IDLE gets closed.
>=20
> fileout =3D csv.writer(file("contact_mod1.csv", "w"))
Instead of passing the file constructor like this, store it locally
first: fp =3D file("foo", "w") and then csv.writer(fp). You can then
simply fp.close() it.
Gerrit.
--=20
231. If it kill a slave of the owner, then he shall pay slave for slave
to the owner of the house.
-- 1780 BC, Hammurabi, Code of Law
--=20
PrePEP: Builtin path type
http://people.nl.linux.org/~gerrit/creaties/path/pep-xxxx.html
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/
More information about the Tutor
mailing list