With this code snippet * will not do the globe or regular expression in these contexts:
if '*NoCover*' in dc_files: dc_files.remove('*NoCover*')
therefore it would be better to say:
if 'NoCover' in dc_files:
However, we need to find the desired entry to delete in the list without using wildcards.
For a small list, you can iterate over it. Understanding the list would do:
new_dc_files = [dc for dc in dc_files if 'NoCover' not in dc]
This is a compact way of saying:
new_dc_files = list() for dc in dc_files: if 'NoCover' in dc: continue new_dc_files.append(dc)
source share