python - If list object contains something remove from list -
i have python script checks folder new files , copies new files directory. files in such format 1234.txt , 1234_status.txt. should move 1234.txt , leave 1234_status.txt unattended.
here's little piece of code in python
while 1: #retrieves listdir after = dict([(f, none) f in os.listdir (path_to_watch)]) #if after has more files before, adds new files array "added" added = [f f in after if not f in before]
my idea after fills added, checks values have status in , pops array. couldn't find way though : /
thanks in advance, tanel-nils
added = [f f in after if not f in before , '_status' not in f]
i recommend refrain long 1 line statements make code impossible read
Comments
Post a Comment