My Detail file is not a piece of a script or any code, it’s just some login information which are given as variables.
I have a file under the below structure.
How can I import it and is it possible to keep the path without having a folder structure because I do not want to code that piece of information to every script?
A/B/C ( my Script is inside a Folder in C folder )
Basically you create a .env file to store the information and load_dotenv will automatically look for that file without you having to specify the path. I put one into my top-level folder for Python projects and it works just fine. I don’t know how good it is in looking for the file so I’d still keep it close.
To be fair, you should have a central file in a top-level folder. I tested it and I can move several parent-folders up to find the file.
That’s just common practice and propably the way you should just organize it that way.
As for how to traverse folders in general: I think it’s “../” in the path to move to the parent folder.
Exactly True to your statement. If we are not working organized we cannot expect answers would work to our issues.
Yeah it worked. The problem was that It doesn’t seem to work when it is inside a Folder at a level several parent-folders up. When I had it outside of a Parent Folder it worked really nice. I don’t have a requirement to have that file inside a Folder. So your solution worked really nicely.
Thank you for chipping in to help me out. As a self taught person I have learnet something new today. May God guide you throughout your life. TC and have a great day.