perl "-n" option in python?
William Tanksley
wtanksle at dolphin.openprojects.net
Sun May 2 16:27:38 EDT 1999
On 03 May 1999 16:38:53 +0000, Juergen Hoetzel wrote:
>Hi everyone!
Hi, Juergen.
>I switched from perl to python some months ago.
We understand.
>One think i liked in perl was the "-n" option to assume a 'while (<>) {
>... } loop around the script. I used this option to do some quick jobs on
>the command line. For example:
>perl -n -e "/regex/ && print"
>So i was never forced to use awk/sed.
>Why isn't there something equivalent in python?
I could give a LOT of reasons -- for example, Python doesn't have the
notion of a default argument, so such a thing would be counterproductive
-- but I'll just note that Python isn't made for one-liners.
If you need a one-liner, use Perl instead.
Or, in the above example, grep. :-)
>Juergen
but-then-APL-beats-Perl-at-that-too-ly yr's
--
-William "Billy" Tanksley
"But you shall not escape my iambics."
-- Gaius Valerius Catullus
More information about the Python-list
mailing list