Currently working with the following package structure:
/package
__init__.py
final.py
/write
__init__.py
write.py
/data
backup.txt
backup1.txt
backup2.txt
final.py imports write.py, which should be able to go back one directory and write a series of backup .txt files to /data.
final.py should be able to go into /data during another call and access the backup files, hence the need to save the information in /data.
-
I’m not sure this should be the correct hierarchy for a package file? How would /write create text files in a directory branch separate from itself without using absolute file paths in case the whole project file is moved, say onto a server.
-
Would it be wrong (once the backup.txt files are created) to add a retrieve.py to /data which returns the .txt files in some sort of data structure and make /data a package, or (2) should final.py directly enter /data and retrieve the text files.
To write to an arbitrary location, just pass the full path to
open. For example, assume that you store the path to your data directory in a constant: