I'd like to create a file with path x
using python. I've been using os.system(y)
where y = 'touch %s' % (x)
. I've looked for a non-directory version of os.mkdir
, but I haven't been able to find anything. Is there a tool like this to create a file without opening it, or using system or popen/subprocess?
This question is related to
python
Of course there IS a way to create files without opening. It's as easy as calling os.mknod("newfile.txt")
. The only drawback is that this call requires root privileges on OSX.
Source: Stackoverflow.com