Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Whats the correct way of declaring folder path in python?

I Need to know whats the correct way of declaring folder path , suppose I have a dummy.py file inside a main folder & also Inside main folder 2 child folders are present images & music , now if i want to declare a image22.img from images folder in dummy.py which one is correct among the below two or both ae fine

myimage = "./images.image22.img"

or

myimage = "images.image22.img"  # without ./

had got this doubt as os.path.abspath(myimage) gives the same results for both

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The use of ‘./’ is not obligatory if you’re requesting files from a folder that is on the current path.

So, in this example you don’t need to use ‘./’ :

images/image22.img
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading