is best proceed unparalleled chronicle filename w/ python?


still 'diving in' python, wish certain i'm unaware something. i wrote book extracts files several zip files, saves extracted files together directory. hinder register filenames being over-written, i wrote small duty - i'm only wondering there improved proceed this?
thanks!



def unique_filename(file_name):
counter = 1
file_name_parts = os.path.splitext(file_name) # advantage ('/path/file', '.ext')
while os.path.isfile(file_name):
file_name = file_name_parts[0] + '_' + str(counter) + file_name_parts[1]
opposing += 1
return file_name


i unequivocally do need files unparalleled directory, numbering duplicates unequivocally tolerable case, i'm looking some-more strong slight (tho' i suspect any pointers welcome), nonetheless only certain accomplishes removing finished right way.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?