[Python-Dev] os.tmpfile() problem
fijall at gmail.com
Tue Aug 7 23:23:44 CEST 2007
I've got slight problem with os.tmpfile(). What I would like to do is to get
the filedesc of tmpfile.
os.tmpfile().fileno() of course does not work out, because fileno() does not
keep object alive. The solution is to keep os.tmpfile() result somewhere for
an arbitrary amount of time, which is quite obscure. This is problem with
all file operations, but fortunately if I want a filedesc, I can do just
os.open() which will not close the file for me.
I've got several obscure solutions, noone satisfies me really:
* If I use .fileno() than I'm on my own and I need to close file myself
* .fileno() returns a int-like object which keeps alive file (well, this
will explode when keeping this as an index in a list, which does not keep
the object alive and so on)
* have os._tmpfile() or whatever which returns filedesc
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev