Other File-Related Modules

fcntl

  • Provides access to the fcntl() system call and file-locking operations
     import fcntl, FCNTL
     # Lock a file
     fcntl.flock(f.fileno(),FCNTL.LOCK_EX)

tempfile

  • Creates temporary files

gzip

  • Creates file objects with compression/decompression
  • Compatible with the GNU gzip program.
     import gzip
     f = gzip.open("foo","wb")
     f.write(data)
     f.close()
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 42
July 17, 2000, beazley@cs.uchicago.edu
>>>