title: Python global variable in open file
body: <p>Hi guys I have question about global variable. How can I put filename into varibale and call it on global.
  My code:</p>
  
  <pre><code>for filename in dirs:
      if filename.startswith("EPG_NatGeo"):
              z = filename
  
  
  output_file = open('nat.xml','w') 
  with open (r'{}','r').format(z) as file:
  </code></pre>
  
  <p>How can varibale became file for opening? Thx for reading this post!</p>