Movatterモバイル変換


[0]ホーム

URL:


Up one LevelPython Library ReferenceContentsModule IndexIndex


36.2.1 File Operations

locking(fd, mode, nbytes)
Lock part of a file based on file descriptorfd from the C runtime. RaisesIOError on failure. The locked region of the file extends from the current file position fornbytes bytes, and may continue beyond the end of the file.mode must be one of theLK_* constants listed below. Multiple regions in a file may be locked at the same time, but may not overlap. Adjacent regions are not merged; they must be unlocked individually.

LK_LOCK
LK_RLCK
Locks the specified bytes. If the bytes cannot be locked, the program immediately tries again after 1 second. If, after 10 attempts, the bytes cannot be locked,IOError is raised.

LK_NBLCK
LK_NBRLCK
Locks the specified bytes. If the bytes cannot be locked,IOError is raised.

LK_UNLCK
Unlocks the specified bytes, which must have been previously locked.

setmode(fd, flags)
Set the line-end translation mode for the file descriptorfd. To set it to text mode,flags should beos.O_TEXT; for binary, it should beos.O_BINARY.

open_osfhandle(handle, flags)
Create a C runtime file descriptor from the file handlehandle. Theflags parameter should be a bit-wise OR ofos.O_APPEND,os.O_RDONLY, andos.O_TEXT. The returned file descriptor may be used as a parameter toos.fdopen() to create a file object.

get_osfhandle(fd)
Return the file handle for the file descriptorfd. RaisesIOError iffd is not recognized.


Up one LevelPython Library ReferenceContentsModule IndexIndex

Release 2.5.2, documentation updated on 21st February, 2008.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2025 Movatter.jp