I have a series of scripts which retrieve files. None of these scripts should continue if the file to be retrieved already exists in the archive. Here is the code:
if f in path(self.storage.archive).files('*'): print f, "exists in archive. Not continuing" sys.exit() self.storage is a class which gives me object-oriented access to the filesystem directories that will be manipulated by the script. E.g. self.storage.archive is a string which refers to a certain directory. Initializing this object initializes all the members (input, archive, output, workfiles) and makes all the correct directories. ok, so I'm thinking of adding a method to the storage class so I can do this: self.storage.archive_has(f, print_msg=True) and sys.exit() but really there is no need to hardcode which storage directory. So I'm thinking: self.storage.memberof('archive', f, print_msg=Tree) and sys.exit() Is that the best solution you can think of? -- http://mail.python.org/mailman/listinfo/python-list