"That name can be retrieved from the name member of the file object."

means that you can get the name of the temporary file created like so:

In [4]: import tempfile

In [5]: tf = tempfile.NamedTemporaryFile()  
In [6]: tf.name  # retrieve the name of the temp file just created
Out[6]: 'c:\\blabla\\locals~1\\temp\\tmptecp3i'

Note: By default the file will be deleted when it is closed. However, if the delete parameter is False, the file is not automatically deleted. See the Python docs on this for more information.

Since you can retrieve the name of each of the 50 temp files you want to create, you can save them, e.g., in a list, before you use them again later (as you say). Just be sure to set the delete value accordingly so that the files don't disappear when you close them (in case you plan to close, and then later reopen them).

I explained how to create temporary filenames in more detail here Best way to generate random file names in Python

Answer from Levon on Stack Overflow
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ tempfile.html
tempfile โ€” Generate temporary files and directories
Use of this function may introduce a security hole in your program. By the time you get around to doing anything with the file name it returns, someone else may have beaten you to the punch. mktemp() usage can be replaced easily with NamedTemporaryFile(), passing it the delete=False parameter:
๐ŸŒ
GitHub
gist.github.com โ€บ raprasad โ€บ a8b1e4d72d60622e9b5b2222208fdd4d
example of NamedTemporaryFile ยท GitHub
example of NamedTemporaryFile. GitHub Gist: instantly share code, notes, and snippets.
๐ŸŒ
Python Module of the Week
pymotw.com โ€บ 2 โ€บ tempfile
tempfile โ€“ Create temporary filesystem resources. - Python Module of the Week
import os import tempfile temp = tempfile.NamedTemporaryFile() try: print 'temp:', temp print 'temp.name:', temp.name finally: # Automatically cleans up the file temp.close() print 'Exists after close:', os.path.exists(temp.name)
๐ŸŒ
Medium
siddharth1.medium.com โ€บ temp-files-and-tempfile-module-in-python-with-examples-570b4ee96a38
temp files and tempfile module in python(with examples) | by Siddharth Kshirsagar | Medium
August 6, 2020 - tempfile.NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix=None, prefix=None, dir=None, delete=True, *, errors=None)
๐ŸŒ
ProgramCreek
programcreek.com โ€บ python โ€บ example โ€บ 335 โ€บ tempfile.NamedTemporaryFile
Python Examples of tempfile.NamedTemporaryFile
def isUpdatesAvailable(cls, path): if sys.version_info < (3, 0): return False # pylint: disable=broad-except if not os.path.isfile(os.path.join(path, "files.xml")): return True try: available = dict() for it in ET.parse(os.path.join(path, "files.xml")).iter(): if it.tag == "File": available[it.text] = datetime.datetime.strptime(it.attrib["Modified"], "%d-%m-%Y") path = NamedTemporaryFile() path.close() urllib.request.urlretrieve("https://www.gurux.fi/obis/files.xml", path.name) for it in ET.parse(path.name).iter(): if it.tag == "File": tmp = datetime.datetime.strptime(it.attrib["Modified"], "%d-%m-%Y") if not it.text in available or available[it.text] != tmp: return True except Exception as e: print(e) return True return False
๐ŸŒ
Linux Hint
linuxhint.com โ€บ tempfile_python
Working with tempfile in python โ€“ Linux Hint
One line of text is written to the file and read from the file like the previous example. It is mentioned before that the temporary file deletes automatically when close() method is called. After delete, โ€˜osโ€™ module is used here to check the temporary file exists or not. # Import tempfile module import tempfile # Import os module import os # Declare object to open temporary file for writing tmp = tempfile.NamedTemporaryFile('w+t') # Declare the name of the temporary file tmp.name="temp.txt" try: # Print message before writing print('Write data to temporary file...') # Write data to the tem
๐ŸŒ
Medium
medium.com โ€บ @pijpijani โ€บ efficient-management-of-temporary-files-with-namedtemporaryfile-in-python-b8d48cbcab45
Efficient Management of Temporary Files with NamedTemporaryFile in Python | by Pikho | Medium
March 12, 2023 - NamedTemporaryFile is a Python function that creates a temporary file with a unique name in a specified directory, which can be used for storing temporary data. When you use NamedTemporaryFile, a file object is returned, which can be used to read from or write to the temporary file.
Find elsewhere
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ the-python-tempfile-module
The Python tempfile Module
July 20, 2023 - In our previous example, we have seen that the temporary file created using the TemporaryFile() function is actually a file-like object without an actual file name. Python also provides a different method, NamedTemporaryFile(), to create a file with a visible name in the file system.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-tempfile-module
Python tempfile module - GeeksforGeeks
December 11, 2020 - If your application spans multiple processes, or even hosts, naming the file is the simplest way to pass it between parts of the application. The NamedTemporaryFile() function creates a file with a name, accessed from the name attribute.
๐ŸŒ
Modular
docs.modular.com โ€บ apis
NamedTemporaryFile | Modular
from tempfile import NamedTemporaryFile ... NamedTemporaryFile(mode="rw") as f: p = f.name f.write("Hello world!") f.seek(0) print( f.read() == "Hello world!" ) print(String(p), p.exists()) #Removed by default...
๐ŸŒ
Echorand
echorand.me โ€บ posts โ€บ named_temporary_file
tempfile.NamedTemporaryFile() in Python - Exploring Software
January 20, 2016 - from tempfile import NamedTemporaryFile f = NamedTemporaryFile() # Change the file name to something f.name = 'myfilename.myextension' # use f
๐ŸŒ
Geek Python
geekpython.in โ€บ tempfile-in-python
How To Use tempfile To Create Temporary Files and Directories in Python
August 15, 2023 - Also, the following example will show us how to write and read text data into the temporary file. In the above code, we used the with statement to create a temporary file and then opened it in text mode('w+t') and did everything the same as we do for handling other files in Python. To take more control over making the temporary file like naming the temporary file as we want or keeping it or deleting it, then we can use NamedTemporaryFile().
๐ŸŒ
Modular
docs.modular.com โ€บ tempfile โ€บ tempfile โ€บ namedtemporaryfile
NamedTemporaryFile | Mojo
March 19, 2026 - Example: from std.tempfile import NamedTemporaryFile ยท from std.pathlib import Path ยท var p: Path ยท
๐ŸŒ
Adam Johnson
adamj.eu โ€บ tech โ€บ 2024 โ€บ 12 โ€บ 30 โ€บ python-temporary-files-directories-unittest
Python: create temporary files and directories in unittest - Adam Johnson
December 30, 2024 - To disable the cleanup, add delete=False to the context manager, plus a print() to display the path. For example, for a file: def setUp(self): super().setUp() self.temp_file = self.enterContext( - NamedTemporaryFile(mode="w+", suffix=".html") + NamedTemporaryFile(mode="w+", suffix=".html", delete=False) ) + print("๐Ÿ˜…", self.temp_file.name)
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ create-temporary-files-and-directories-using-python-tempfile
Create temporary files and directories using tempfile - GeeksforGeeks
July 15, 2025 - The NamedTemporaryFile() function creates a file in the same way as TemporaryFile() but with a visible name in the file system.
๐ŸŒ
TakoVibe
takovibe.com โ€บ home โ€บ blog โ€บ python tempfile explained: temporary files, auto-deletion & common mistakes
Python tempfile Explained: Temporary Files, Auto-Deletion & Common Mistakes | Rahul Beniwal | TakoVibe
August 21, 2025 - from tempfile import TemporaryDirectory, NamedTemporaryFile with TemporaryDirectory() as dirname: print('directory is:', dirname) with NamedTemporaryFile('w', dir=dirname) as f: print('filename is:', f.name) f.write('Hello World\n')
๐ŸŒ
DNMTechs
dnmtechs.com โ€บ using-tempfile-namedtemporaryfile-in-python-3
Using tempfile.NamedTemporaryFile() in Python 3 โ€“ DNMTechs โ€“ Sharing and Storing Technology Knowledge
temp_file = tempfile.NamedTemporaryFile(mode='w+') In this example, the temporary file is opened in text mode, allowing us to write and read strings directly without encoding or decoding.