posixfile
posixfile object
This module implements some additional functionality over the built-in
file objects. In particular, it implements file locking, control over
the file flags, and an easy interface to duplicate the file object.
The module defines a new file object, the posixfile object. It
inherits all the standard file object methods and adds the methods
described below.
To instantiate a posixfile object, use the open() function in
the posixfile module. The resulting object looks and feels the same as
a standard file object.
The posixfile module defines the following constants:
The posixfile module defines the following functions:
The posixfile object defines the following additional methods:
All methods return IOError when the request fails.
Format characters for the lock() method have the following meaning:
In addition the following modifiers can be added to the format:
Note:
(1) The lock returned is in the format (mode, len, start,
whence, pid) where mode is a character representing the type of lock
('r' or 'w'). This modifier prevents a request from being granted; it
is for query purposes only.
Format character for the flags() method have the following meaning:
In addition the following modifiers can be added to the format:
Note:
(1) The ! and = modifiers are mutually exclusive.
(2) This string represents the flags after they may have been altered
by the same call.
Examples:
from posixfile import *
file = open('/tmp/test', 'w')
file.lock('w|')
file.lock('u')
file.close()