Created
March 24, 2025 05:15
-
-
Save pepoluan/135956344c70c8834053c58c40b7e8de to your computer and use it in GitHub Desktop.
Create a filename that does not exist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
fromt pathlib import Path | |
def file_that_does_not_exist() -> Path: | |
def _randname() -> str: | |
return "".join( | |
random.choice(string.ascii_lowercase) | |
for _ in range(8) | |
) | |
while (fp := Path(_randname())).exists(): | |
pass | |
return fp | |
print(f"This file does not exist: '{file_that_does_not_exist()}'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment