Python Forum
Make the script read from any directory - 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: Make the script read from any directory (/thread-27651.html)



Make the script read from any directory - falahfakhri - Jun-15-2020

Hi,

How could I make the script read the data from any directory,

I'd like to make it something like this,

product_path = os.path.join('product_path')
user_input_dir = input('\nPlease enter your directory path\n' + product_path)

It doesn't work,

Any suggestions please!


RE: Make the script read from any directory - buran - Jun-15-2020

this line is not doing anything
product_path = os.path.join('product_path')
this line will not produce the full path
user_input_dir = input('\nPlease enter your directory path\n' + product_path)
you want
user_input_dir = input('\nPlease enter your directory path\n')
product_path = os.path.join('product_path', user_input_dir) # assuming 'product path' is real dir



RE: Make the script read from any directory - falahfakhri - Jun-15-2020

Thanks a lot for your very nice explanation.