[Tutor] Can tempfile.NamedTemporaryFile(delete=False) be used to create *permanent* uniquely named files?
alan.gauld at yahoo.co.uk
Sun Oct 21 03:59:25 EDT 2018
On 21/10/18 07:13, boB Stepp wrote:
> My initial thought was to just have a sequence of game names with
> incrementing numerical suffixes: game_0, game_1, ... , game_n. But
> this would require the program to keep track of what the next
> available numerical suffix is.
The traditional approach to such scenarios (eg. for log files)
is to append the datetime. If that is not enough granularity
you can additionally append a numeric suffix that applies
only during a single session(ie a global variable) and is
only applied when the datetimes are identical - very rare.
> tempfile.NamedTemporaryFile(delete=False) would solve this problem
Can't help there, I've never used it. :-)
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor