-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Specify tempfile random naming constraints #24785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Specify which random characters are used during temporary file name creation
This PR is stale because it has been open for 30 days with no activity. |
I would like this added to the documentation. |
@vstinner may I ask you to review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, though I wonder if this should be spelled out (lowercase alphanumeric characters plus the underscore) instead of using a regex-like expression, since I also couldn't find many examples of a-z
being used outside of a regex context. Not too sure which is better though, so I'll let someone else chime in on this
Thanks for the PR, but this feels like an implementation detail. Would you mind talking more about the use case you have for the exact set of characters used to be a documented guarantee? |
@hauntsaninja I don't exactly want a guarantee or whatnot. At the time of creating this PR, I want to know what the tempfile's randomly generated names would look like, and for my use case at the time, I wanted to generate my own files ensuring I would confuse them for the tempfile's random names. So I decided to look at the source code to see what kind of characters would be used to create the tempfiles, so I decided to document it so that others who had the same inquiry as me would know. |
Okay, thanks, that helps me better understand the use case. I think the right way to disambiguate temporary files from other files is to use the Putting statements in the documentation is essentially a guarantee. I appreciate your intention to save time for others, but curiosity about implementation details is still best served by looking at the implementation (one of my favourite things about Python is that the standard library is quite readable). |
Specify which random characters are used during temporary file name creation. Trivial PR, but it may be helpful for developers to know what characters are used during file creation. Source:
class _RandomNameSequence