I am relatively new to Python and just have a couple quick questions about using file paths in Python code.

1) As I was recently playing around with the command line, I could not get a file path to work correctly unless I used forward slashes in the path...for example:

reader = csv.reader(open('C:/Folder/Folder/file.txt', 'wb'))

However, I wrote a program previously that used the backslash and everything worked just fine. Is there a time to use the backslash and time to use the forward slash or does it not matter?

2) I was also trying to use the path to a shared file on the network drive recently and Python did not seem to like the path

path = "\\VPC\Scala Test\Movies 10-12-09"

for example. Can shared folders be referenced in a Python program or do the files have to be on the hard drive of the computer the program is written on?


6 Years
Discussion Span
Last Post by richieking

backslash is native to windows as forwardslash to linux/unix/bsd file path. if you want to write an app. for network , then your good choice shout be forwardslash.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.