We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,382 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

File Paths in Python

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?

Thanks

2
Contributors
1
Reply
35 Minutes
Discussion Span
2 Years Ago
Last Updated
2
Views
Question
Answered
rhuffman8
Light Poster
35 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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.

richieking
Master Poster
789 posts since Jun 2009
Reputation Points: 58
Solved Threads: 156
Skill Endorsements: 0
Question Answered as of 2 Years Ago by richieking

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0520 seconds using 2.63MB