#NEWLINE# def backup_dir( dir , ext = '.bak' ) : #NEWLINE# #INDENT# 'Figure out the name of a directory to back up the given dir to\n    (adding .bak, .bak2, etc)' #NEWLINE# n = 1 #NEWLINE# extension = ext #NEWLINE# while os . path . exists ( ( dir + extension ) ) : #NEWLINE# #INDENT# n += 1 #NEWLINE# extension = ( ext + str ( n ) ) #NEWLINE# #UNINDENT# return ( dir + extension )