title: Creating a filename dynamically based on the argument passed to a function
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11583526/python-obtain-variable-name-of-argument-in-a-function">python obtain variable name of argument in a function</a>  </p>
  </blockquote>
  
  
  
  <p>I have the following code which creates a file list.txt,currently i hard-code the filename as 'list.txt',is there a way we can create the filename dynamically based on the argument name passed to the function Eg..list is passed as argument here in this example,so file name should be list.txt,if the parameter is list2.txt,file name should be list2.txt .....</p>
  
  <pre><code>def filecreation(list):
      #print "list"
      with open('list.txt', 'w') as d:
          d.writelines(list)
  
  def main():
      list=['206061\n', '202086\n', '206062\n']
      filecreation(list)
  
  if __name__ == '__main__':
      main()
  </code></pre>