Best way to test if a file descriptor is valid?
Noah
noah at noah.org
Mon Feb 24 22:26:48 EST 2003
I have a method that is passed an open file descriptor.
This file descriptor may have been opened from a file or
from a serial device or whatever. Is there a good way to test if
the file descriptor is valid and available for read/write?
Currently I'm doing this:
try:
os.fstat(command)
except OSError:
raise Exception, 'Command is not a valid file descriptor.'
Which is OK I guess... Is there another way?
Yours,
Noah
More information about the Python-list
mailing list