<file object>.truncate()

Bjoern Lindstroem magog at swipnet.se
Sat May 20 19:36:02 EDT 2000


When I do the following:

f = open('file', 'w')
f.truncate(3)
f.close()

the file becomes corrupted. It has the wished size, but it is all null
bytes.

The Library Reference says that 'the availability of this function
depends on the operating system version'. So if it helps, I am running
Linux 2.2.14.

If it really is the case that <file object>.truncate() is not
available, what is the best way to get the same result?
-- 
| )  o o      |       |      o o   bkhl at swipnet.se
|-. o _ ._._  | o._  _| __|_.__ ._ _  http://home.swipnet.se/bkhl
|__)|(_)| | | |_|| |(_|_> |_|(_)| | |    PGP Public key on home page
   _|                                       and keyserver, ID 6F580C70



More information about the Python-list mailing list