title: Reading from stdin with a system argv
body: <p>I am attempting to cat a CSV file into stdout and then pipe the printed output as input into a python program that also takes a system argument vector with 1 argument. I ran into an issue I think directly relates to how Python's fileinput.input() function reacts with regards to occupying the stdin file descriptor.</p>
  
  <pre><code>generic_user% cat my_data.csv | python3 my_script.py myarg1
  </code></pre>
  
  <p>Here is a sample Python program:</p>
  
  <pre><code>import sys, fileinput
  
  def main(argv):
      print("The program doesn't even print this")
      data_list = []
      for line in fileinput.input():
          data_list.append(line)
  
  if __name__ == "__main__":
      main(sys.argv)
  </code></pre>
  
  <p>If I attempt to run this sample program with the above terminal command and no argument myarg1, the program is able to evaluate and parse the stdin for the data output from the CSV file.</p>
  
  <p>If I run the program with the argument myarg1, it will end up throwing a FileNotFoundError directly related to myarg1 not existing as a file.</p>
  
  <p><code>FileNotFoundError: [Errno 2] No such file or directory: 'myarg1'</code></p>
  
  <p>Would someone be able to explain in detail why this behavior takes place in Python and how to handle the logic such that a Python program can first handle stdin data before argv overwrites the stdin descriptor?</p>