I am working to add a file in temporary folder like so:
self._dir = tempfile.mkdtemp()
self._dir = os.path.join(self._dir, "test")
os.mkdir(self._dir)
self.checkpoint = os.path.join(self._dir, "file.txt")
So the above in the init function.
and when I call my main function, I only see the test folder and there is no file.txt along with it.
how can i solve this?
Based on the code you have provided, that is the expected behaviour.
os.mkdircreates the directory, but there is no other code to create a text file -os.path.joinonly joins two or more filenames into one combined filename, it doesn't create anything.If you want to create the text file, you would probably need to add something like