A version of touch() for Python3.2; use now as time

This commit is contained in:
Doug Blank 2016-01-28 16:57:06 -05:00
parent de07b9d4f1
commit c28c49ba67

View File

@ -76,7 +76,7 @@ def touch(fname, mode=0o666, dir_fd=None, **kwargs):
## After http://stackoverflow.com/questions/1158076/implement-touch-using-python
if sys.version_info < (3, 3, 0):
with open(fname, 'a'):
os.utime(fname, times)
os.utime(fname, None) # set to now
else:
flags = os.O_CREAT | os.O_APPEND
with os.fdopen(os.open(fname, flags=flags, mode=mode, dir_fd=dir_fd)) as f: