File name from file descriptor?
Carsten Gaebler
clpy at snakefarm.org
Fri Jun 22 10:45:50 EDT 2001
More information about the Python-list mailing list
Fri Jun 22 10:45:50 EDT 2001
- Previous message (by thread): File name from file descriptor?
- Next message (by thread): File name from file descriptor?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Carlos Ribeiro wrote: > functionality depend a lot on the OS being used. Could you please tell us > why do you *need* to make it work using file descriptors? The problem is this: I have a script that is called like ./myscript.py < somefile where somefile is a text file which may or may not be gzipped. To determine whether or not the data is gzipped I read in one byte via the gzip module. If that raises an exception I know the data is not gzipped. But I'd miss the first byte if it is gzipped. Yes, I could store this byte somewhere and then pass it around somehow, but ... you know? :-) So I'd like to open a second 'instance' of the file for reading but I only have sys.stdin's file descriptor. cg. > > At 14:03 22/06/01 +0200, Carsten Gaebler wrote: > >Hi there! > > > >How can I determine a file's name if I only have the file descriptor? > >os.fdopen(fd).name just returns '(fdopen)'. > >
- Previous message (by thread): File name from file descriptor?
- Next message (by thread): File name from file descriptor?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list