The most secure method to do what you are asking for is, as Dan points out there is no need to specify any name to the file, I am only using suffix and prefix as OP asked for it in the question.
import os
import tempfile as tfile
fd, path = tfile.mkstemp(suffix=".txt",prefix="abc") #can use anything
try:
with os.fdopen(fd, 'w') as tmpo:
# do stuff with temp file
tmpo.write('something here')
finally:
os.remove(path)
to understand more about the security aspects attached to this you can refer to this link
well if you can't use os and are required to perform these actions then consider using the following code.
import tempfile as tfile
temp_file=tfile.NamedTemporaryFile(mode="w",suffix=".xml",prefix="myname")
a=temp_file.name
temp_file.write("12")
temp_file.close()
a will give you the complete path to the file eg as:
'/tmp/mynamesomething.xml'
in case you don't want to delete the file in the end then use:
temp_file=tfile.NamedTemporaryFile(delete=False) #along with other parameters of course.
tempfilepackage and concerning about lost parameter.