Python Forum
Python 3.6.5 - Saving files - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python 3.6.5 - Saving files (/thread-11689.html)



Python 3.6.5 - Saving files - Mradr - Jul-21-2018

Hello, today I upgrade to 3.6.5 and notice something very different right off the bat. I been using 2.7, 3.5 and never had this issue before - but when I save/read files, open(), the file longer is created in root of where I start the command. Aka, if I create a bat file to start the program - it usually made that the root and started from there in terms of reading or editing files. Instead, it seems like it is not saving in the same place and saving some place else I can not find. It seems python made some more changes under the hood that I don't seem to like if this is the case:) but I need to know where it is saving any files at. Is there a way to see the full path a file is being created/saved at?

os.getcwd() shows the current path seems like something in 3.6.5 is off here.


RE: Python 3.6.5 - Saving files - Larz60+ - Jul-22-2018

show code, it's really not possible to answer correctly without, but I'm guessing you want to assure that the data file is in the same directory as the program that creates it. You can assure this by adding the following code at the start of your program:
import os

# add the following to your first run function, class or method
os.chdir(os.path.dirname(__file__))