title: In Python, using concatenation inside open()
body: <p>I'm wondering how to combine the items inside of the open() function to end in:</p>
  
  <pre><code>FieldFile = open(r'C:\Users\Data1.txt')
  </code></pre>
  
  <p>So, in the context of having the following code and wanting to open the contents of "File1" and name the contents "FieldFile":</p>
  
  <pre><code>File1 = r'C:\Users\Data1.txt'
  File2 = r'C:\Users\Data2.txt'
  File3 = r'C:\Users\Data3.txt'
  PointID = '1'
  
  FieldFile = open('File' + PointID)
  </code></pre>
  
  <p>'File' and PointID are both text strings it looks like to me, therefore:</p>
  
  <pre><code>print 'File' + PointID
  </code></pre>
  
  <p>yields</p>
  
  <pre><code>File1
  </code></pre>
  
  <p>which has been set to:</p>
  
  <pre><code>File1 = r'C:\Users\Data1.txt'
  </code></pre>
  
  <p>So why doesn't the code snippet open 'File1' if I am basically doing the following? </p>
  
  <pre><code>FieldFile = open(File1)
  </code></pre>