Problem: The doc for os.ttyname says it accepts an fd What Happens: It raises a type error and says it expects an integer instead. Experimentally, it seems to accept fd.fileno() as input What should happen: It should an accept an fd (file object) I have attached a test case for this. The output I get using python 2.2 & 2.3 is: Documentation Sez: ------------------------------------------------------------ ttyname(fd) -> String Return the name of the terminal device connected to 'fd'. ------------------------------------------------------------ TTY Name (should work): exceptions.TypeError an integer is required TTY Name (shouldn't work): /dev/pts/2 Ciao!
Logged In: YES user_id=11375 No, file descriptors are small integers corresponding to a file opened by the current process. File descriptors are not the same as file objects; as you've discovered, you can get the file descriptor for a file object by calling the .fileno() method.