In the Unix shell I can do this to empty a file:
cd /the/file/directory/ :> thefile.ext
How would I go about doing this in Python?
Alternate form of the answer by @rumpel
with open(filename, 'w'): pass