title: What is the proper way to take a directory path as user input?
body: <p>Below is a snippet of code I am trying to use to take a directory path as "raw input" from the user. I receive the following error after the input is taken from the user:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\larece.johnson\Desktop\Python Programs\Hello World 2", line 14, in &lt;module&gt;
      f = open(str,"r+")                                     #I open the text file here which the user gave me
  IOError: [Errno 2] No such file or directory: 'C:/Users/larece.johnson/Desktop/Python Programs/BostonLog.log.2014-04-01'
  </code></pre>
  
  <p>Ignoring what I have done below, is there a particular way I am supposed to take the path from user so that Python accepts it? </p>
  
  <p>For example, the directory and file I'm looking for is </p>
  
  <pre><code>C:/Users/larece.johnson/Desktop/Python Programs/BostonLog.log.2014-04-01
  </code></pre>
  
  
  
  <pre><code>import re     #this library is used so that I can use the "search" function
  import os     #this is needed for using directory paths and manipulating them 
  
  str =""       #initializing string variable for raw data input
  
  #print os.getcwd()
  #f = open("C:/Users/larece.johnson/Desktop/BostonLog.log.2014-04-02.log","r+")
  
  str = raw_input("Enter the name of your text file - please use / backslash when typing in directory path: ");  #User will enter the name of text file for me
  
  f = open(str,"r+")
  </code></pre>