[Tutor] Diamond Equivalent

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Sep 23 01:31:30 CEST 2005



On Thu, 22 Sep 2005 kim.d at tesco.net wrote:

> I am coming to Python from Perl. Does Python have anything like the
> diamond operator found in Perl?

Hi Kim,


According to 'perldoc perlop':

"""
       The null filehandle <> is special: it can be used to emulate the
       behavior of sed and awk.  Input from <> comes either from standard
       input, or from each file listed on the command line.  Here's how it
       works: the first time <> is evaluated, the @ARGV array is checked,
       and if it is empty, $ARGV[0] is set to "-", which when opened gives
       you standard input.  The @ARGV array is then processed as a list
       of filenames.
"""

Python includes a module called 'fileinput' that does sorta this:

    http://www.python.org/doc/lib/module-fileinput.html

If you have more questions, please feel free to ask.  Good luck to you!



More information about the Tutor mailing list