title: Python read from command line arguments or stdin
body: <p>When writing text-oriented command line programs in Python, I often want to read either all the files passed on the command line, or (XOR) standard input (like Unix <code>cat</code> does, or Perl's <code>&lt;&gt;</code>). So, I say</p>
  
  <pre><code>if len(args) == 0:  # result from optparse
      input = sys.stdin
  else:
      input = itertools.chain(*(open(a) for a in args))
  </code></pre>
  
  <p>Is this the Pythonic way of doing this, or did my miss some part of the library?</p>