Re: tempfile.mkstemp and os.fdopen

2007-08-29 Thread billiejoex
Gabriel Genellina wrote: > As someone already suggested, why don't you use TemporaryFile or > NamedTemporaryFile and avoid such problems? Because I don't want file to be removed after closing. -- http://mail.python.org/mailman/listinfo/python-list

Re: tempfile.mkstemp and os.fdopen

2007-08-29 Thread Nick Craig-Wood
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > In message <[EMAIL PROTECTED]>, Michael > J. Fromberger wrote: > > > ... since os.fdopen() only has access to the file descriptor, it > > does not have a convenient way to obtain the file's name. > > You can do this under Linux as follows: > >

Re: tempfile.mkstemp and os.fdopen

2007-08-29 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Michael J. Fromberger wrote: > ... since os.fdopen() only has access to the file descriptor, it > does not have a convenient way to obtain the file's name. You can do this under Linux as follows: os.readlink("/proc/%d/fd/%d" % (os.getpid(), fileno)) -- http:

Re: tempfile.mkstemp and os.fdopen

2007-08-29 Thread Gerard Flanagan
On Aug 28, 7:55 pm, billiejoex <[EMAIL PROTECTED]> wrote: > Hi there. > I'm trying to generate a brand new file with a unique name by using > tempfile.mkstemp(). > In conjunction I used os.fdopen() to get a wrapper around file > properties (write & read methods, and so on...) but 'name' attribute >

Re: tempfile.mkstemp and os.fdopen

2007-08-28 Thread Gabriel Genellina
On 28 ago, 22:21, billiejoex <[EMAIL PROTECTED]> wrote: > Another question: I have to open file for writing ('wb') but I noticed > that both tempfile.mkstemp() and os.fdopen() accept a "mode" argument. > It's not clear *when* do I have to specify

Re: tempfile.mkstemp and os.fdopen

2007-08-28 Thread billiejoex
Thanks all. Another question: I have to open file for writing ('wb') but I noticed that both tempfile.mkstemp() and os.fdopen() accept a "mode" argument. It's not clear *when* do I have to specify such mode. When using tempfile.mkstemp? >>> fileno, name = t

Re: tempfile.mkstemp and os.fdopen

2007-08-28 Thread Nick Craig-Wood
billiejoex <[EMAIL PROTECTED]> wrote: > I'm trying to generate a brand new file with a unique name by using > tempfile.mkstemp(). > > Moreover, I'd like to know if I'm doing fine. Does this approach avoid > race conditions This is a reasonably secure way of doing things. It can't race under

Re: tempfile.mkstemp and os.fdopen

2007-08-28 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, billiejoex <[EMAIL PROTECTED]> wrote: > Hi there. > I'm trying to generate a brand new file with a unique name by using > tempfile.mkstemp(). > In conjunction I used os.fdopen() to get a wrapper around file > properties (write & read methods, and so on...) but 'nam

Re: tempfile.mkstemp and os.fdopen

2007-08-28 Thread [EMAIL PROTECTED]
On Aug 28, 1:55 pm, billiejoex <[EMAIL PROTECTED]> wrote: > In conjunction I used os.fdopen() to get a wrapper around file > properties (write & read methods, and so on...) but 'name' attribute > does not contain the correct file name. Why? > > >>> import os > >>> import tempfile > >>> fileno, nam

tempfile.mkstemp and os.fdopen

2007-08-28 Thread billiejoex
Hi there. I'm trying to generate a brand new file with a unique name by using tempfile.mkstemp(). In conjunction I used os.fdopen() to get a wrapper around file properties (write & read methods, and so on...) but 'name' attribute does not contain the correct file name. Why? >>> import os >>> impor