Screwing Up looping in Generator

Sayth Renshaw flebber.crue at gmail.com
Tue Jan 3 21:09:35 EST 2017


Untested as i wrote this in notepad at work but, if i first use the generator to create a set of filenames and then iterate it then call the generator anew to process file may work?
Good idea or better available?
def get_list_of_names(generator_arg):
 name_set = set()
 for name in generator_arg:
 base = os.path.basename(name.name)
 filename = os.path.splitext(base)[0]
 name_set.add(filename)
 return name_set
 for file_name in name_set: 
 directory = "output"
 with open(os.path.join(directory, filename, 'w', newline='') as csvf: 
 for file in rootobs: 
 # create and write csv 
Sayth


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /