def getOldestFile(files): if not files: return None now = time.time() oldest = (files[0], now - sfile.ctime(files[0])) for f in files[1:]: age = now - sfile.ctime(f) if age > oldest[1]: oldest = (f, age) return oldest[0]