jeudi 14 juillet 2016

Should I use assert to cross reference command line arguments with a metadata file?

Is this the proper way to use assert?

My program takes some files names as command line arguments and stores them in a list. I need to cross reference the list of file names with names in a metadata file. If one of the files isn't in the metadata, I want the program to end and explain why. I thought assert might be good for that but I'm not sure if this is the proper way to use it or if there is a better way to iterate over a list and make sure it exists in the metadata.

for sample in samples_list:
    assert(sample in meta_sampleIds), "A file is missing from the metadata, or error in get_data()"

Aucun commentaire:

Enregistrer un commentaire