Python vs. Perl, which is better to learn?
Aahz
aahz at pythoncraft.com
Thu May 2 17:09:11 EDT 2002
In article <9IcA8.90097$vF6.2684221 at news2.tin.it>,
Alex Martelli <aleax at aleax.it> wrote:
>Aahz wrote:
>>
>> What I'd like is an argument to specify how many command-line args to
>> skip over, say if you're writing something like grep.py.
>
>import fileinput, sys, re
>there = re.compile(sys.argv.pop(1))
>for line in fileinput.input():
> if there.search(line): print line,
Thanks! I don't really like "print line,", because it adds an extra
space that wasn't there before, so I prefer sys.stdout.write(). It's a
matter of taste, though.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"I used to have a .sig but I found it impossible to please everyone..." --SFJ
More information about the Python-list
mailing list