Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103382 > unrolled thread

Re: Make a unique filesystem path, without creating the file

Started byBen Finney <ben+python@benfinney.id.au>
First post2016-02-23 11:18 +1100
Last post2016-02-23 00:53 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Make a unique filesystem path, without creating the file Ben Finney <ben+python@benfinney.id.au> - 2016-02-23 11:18 +1100
    Re: Make a unique filesystem path, without creating the file Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-02-23 00:53 +0000

#103382 — Re: Make a unique filesystem path, without creating the file

FromBen Finney <ben+python@benfinney.id.au>
Date2016-02-23 11:18 +1100
SubjectRe: Make a unique filesystem path, without creating the file
Message-ID<mailman.56.1456187612.20994.python-list@python.org>
Oscar Benjamin <oscar.j.benjamin@gmail.com> writes:

> What does unpredictable mean in this context? Maybe I'm reading too
> much into that...

I think you may be, yes. The request in this thread requires making
direct use of the “generate a new valid temporary fielsystem path”
functionality already implemented in ‘tempfile’.

Implementations of that functionality outside of ‘tempfile’ are a fun
exercise, but miss the point of this thread.

-- 
 \       “But Marge, what if we chose the wrong religion? Each week we |
  `\          just make God madder and madder.” —Homer, _The Simpsons_ |
_o__)                                                                  |
Ben Finney

[toc] | [next] | [standalone]


#103387

FromJon Ribbens <jon+usenet@unequivocal.co.uk>
Date2016-02-23 00:53 +0000
Message-ID<slrnncnbii.16b.jon+usenet@wintry.unequivocal.co.uk>
In reply to#103382
On 2016-02-23, Ben Finney <ben+python@benfinney.id.au> wrote:
> Oscar Benjamin <oscar.j.benjamin@gmail.com> writes:
>> What does unpredictable mean in this context? Maybe I'm reading too
>> much into that...
>
> I think you may be, yes. The request in this thread requires making
> direct use of the “generate a new valid temporary fielsystem path”
> functionality already implemented in ‘tempfile’.
>
> Implementations of that functionality outside of ‘tempfile’ are a fun
> exercise, but miss the point of this thread.

I think you have missed the point of your own thread.

You can't do what you wanted using tempfile, the only possible
answer is to choose a filename that is sufficiently random that
your hope that it is unique won't be proven futile. tempfile has
two main modes, mktemp which meets your requirements but should
never be used as it is insecure, and mkstemp which doesn't meet
your requirements because it fundamentally operates by actually
creating the file in question and relying on the filesystem to
guarantee uniqueness.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web