Does ftruncate work?

Michael Hudson mwh at python.net
Tue Jan 15 06:33:02 EST 2002


bass at slinkp.com (Paul Winkler) writes:

> Can somebody tell me what's wrong here?
> 
> [pw at slink pw]$ touch foo
> [pw at slink pw]$ python
> Python 2.1.1+ (#1, Jan  8 2002, 00:37:12) 
> [GCC 2.95.4 20011006 (Debian prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import os
> >>> print os.ftruncate.__doc__
> ftruncate(fd, length) -> None
> Truncate a file to a specified length.
> >>> f = open('foo', 'rw')
> >>> os.ftruncate(f, 1)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: an integer is required

Why not use f.truncate(1)?

Cheers,
M.

-- 
  Some people say that a monkey would bang out the complete works
  of Shakespeare on a typewriter give an unlimited amount of time.
  In the meantime, what they would probably produce is a valid
  sendmail configuration file.                    -- Nicholas Petreley



More information about the Python-list mailing list