"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
On POSIX (only), a process that ... any NamedTemporaryFiles it created. Raises an auditing event tempfile.mkstemp with argument fullpath. Changed in version 3.8: Added errors parameter. Changed in version 3.12: Added delete_on_close parameter. class tempfile.SpooledTemporaryFile(max_size=0, mode='w+b', ...
๐ŸŒ
Modular
docs.modular.com โ€บ tempfile โ€บ tempfile โ€บ namedtemporaryfile
NamedTemporaryFile | Mojo
March 19, 2026 - with NamedTemporaryFile(mode="rw") ... ยท Set delete=False to keep the file after closing. Use mode="r" for reading, mode="w" for writing, mode="rw" for both....
๐ŸŒ
Real Python
realpython.com โ€บ ref โ€บ stdlib โ€บ tempfile
tempfile | Python Standard Library โ€“ Real Python
Note: The default mode for tempfile.TemporaryFile is "w+b" for binary read/write. You can also set "w+t" for text files. ... >>> with tempfile.NamedTemporaryFile(delete=False) as temp: ... print(temp.name) ...
๐ŸŒ
Python Module of the Week
pymotw.com โ€บ 2 โ€บ tempfile
tempfile โ€“ Create temporary filesystem resources. - Python Module of the Week
The tempfile module provides several functions for creating filesystem resources securely. TemporaryFile() opens and returns an un-named file, NamedTemporaryFile() opens and returns a named file, and mkdtemp() creates a temporary directory and returns its name.
๐ŸŒ
Google Groups
groups.google.com โ€บ g โ€บ dev-python โ€บ c โ€บ 1-cmCnOve08
[Python-Dev] NamedTemporaryFile and context managers
> > ```python > from tempfile import NamedTemporaryFile > > with NamedTemporaryFile() as fp: > fp.write(b'some data') > fp = open(fp.name()) > data = fp.read() > > assert data == 'some_data' > ``` > > Occasionally, it is desirable to close and reopen the temporary file in order to read the contents (there are OSes that cannot open a temp > file for reading while it is still open for writing). This would look like: > What's the problem with `NamedTemporaryFile(mode='w+b')`? (it's actually the default!) You can both read and write without reopening.
๐ŸŒ
Readthedocs
anyio.readthedocs.io โ€บ en โ€บ stable โ€บ tempfile.html
Asynchronous Temporary File and Directory โ€” AnyIO 4.14.2 documentation
from anyio import TemporaryFile, ... f.read()) # Output: Temporary file content run(main) NamedTemporaryFile works similarly to TemporaryFile, but the file has a visible name in the filesystem....
๐ŸŒ
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 - NamedTemporaryFile is used instead of TemporaryFile, to make the file visible in the filesystem. This allows other functions or processes to reopen it by name, available in the name attribute.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-tempfile-module
Python tempfile module - GeeksforGeeks
December 11, 2020 - NamedTemporaryFile returns a file-like object that can be used as temporary storage, however, contrary to TemporaryFile, a file created with NamedTemporaryFile is guaranteed to have a visible name during its lifetime.
๐ŸŒ
Django
code.djangoproject.com โ€บ ticket โ€บ 18744
#18744 (NamedTemporaryFile opened in read mode cannot be written to by another process on Windows) โ€“ Django
The documentation for NamedTemporaryFile says that it exists so that on Windows so other processes can open the file, which is not possible using Python's implementation of NamedTemporaryFile because of the O_TEMPORARY flag that is passed by default. However, if the temporary file is opened in read mode (r+), another process cannot write to the file, unless the temp file is closed before the outside process is called.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ the-python-tempfile-module
The Python tempfile Module
July 20, 2023 - So, the created file actually has a name this time. The advantage of NamedTemporaryFile() is that we can save the name of the created temp files and use them later before closing or destroying it.
๐ŸŒ
Echorand
echorand.me โ€บ posts โ€บ named_temporary_file
tempfile.NamedTemporaryFile() in Python - Exploring Software
January 20, 2016 - from tempfile import NamedTemporaryFile ... open(path).read() # do some work with the data # Or, make a seek(0) call on the file object and read from it # The file mode is by default "w+" which means, you can read from # and write to it....
๐ŸŒ
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)
๐ŸŒ
CodeRivers
coderivers.org โ€บ blog โ€บ python-namedtemporaryfile
Python `NamedTemporaryFile`: A Comprehensive Guide - CodeRivers
February 22, 2026 - NamedTemporaryFile creates a temporary file with a unique name in the operating system's default temporary directory. The file is opened in a mode that can be specified (by default, it's opened in binary read/write mode). One of the key features is that the file is automatically deleted when ...
๐ŸŒ
Linux Hint
linuxhint.com โ€บ tempfile_python
Working with tempfile in python โ€“ Linux Hint
# Import tempfile module import tempfile # Import os module import os # Declare object to create a temporary file with suffix and prefix tmp = tempfile.NamedTemporaryFile(mode='w+t', prefix='tm_', suffix='_fl', dir='/tmp') # Print the temporary filename print(tmp.name) try: # Print message before writing print('Write data to temporary file...') # Write data to a temporary file tmp.write('This is a temporary content.') finally: # Remove the file automatically tmp.close() if(os.path.exists(tmp.name) == False): print('File is removed')
๐ŸŒ
PyTutorial
pytutorial.com โ€บ python-temporary-files-secure-easy-handling
PyTutorial | Python Temporary Files: Secure & Easy Handling
February 6, 2026 - import tempfile import os with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt') as tmp: # Get the file's actual path file_path = tmp.name print(f"Temporary file created at: {file_path}") # Write to it tmp.write("Data inside a named temp file.") # The file persists because delete=False print(f"File still exists?
๐ŸŒ
Modular
docs.modular.com โ€บ apis
NamedTemporaryFile | Modular
Note: NamedTemporaryFile.__init__ document the arguments. ... __init__(out self, mode: String = "w", name: Optional[String] = None, suffix: String = "", prefix: String = "tmp", dir: Optional[String] = None, delete: Bool = True)