News for hackers. Stuff that matters.
Re:Skip grep, use awk by d33 on Tuesday July 04, 2017 @09:18AM (#14695671)
Hey, it would be awesome to have something like this for Python!
Re:Skip grep, use awk by gmfawcett on Tuesday July 04, 2017 @10:15AM (#14695990)
I wrote a little tool called "pyline" about a hundred years ago... I still reach for it often when I'm in a hurry, and don't have time to futz around with awk/sed.

https://code.activestate.com/recipes/437932-pyline-a-grep-li...

Re:Skip grep, use awk by edraferi on Tuesday July 04, 2017 @11:23PM (#14699793)
That's pretty cool, thanks!
Re:Skip grep, use awk by Ultimatt on Tuesday July 04, 2017 @09:31AM (#14695731)
Not really possible in Python for anything overly useful/complex because of the significant white space, and regular expressions are not a first class object in the language. ipython is the equivalent solution I suppose.

However, Ruby completely inherited this aspect of Perl and is another good candidate. It's just even old systems have a perl installed that will perform the awk like functionality.

Re:Skip grep, use awk by phaemon on Tuesday July 04, 2017 @09:40AM (#14695793)
There is "Pyed Piper" aka `pyp`

https://code.google.com/archive/p/pyp/

"Pyp is a linux command line text manipulation tool similar to awk or sed, but which uses standard python string and list methods as well as custom functions evolved to generate fast results in an intense production environment."

Re:Skip grep, use awk by Ultimatt on Tuesday July 04, 2017 @09:44AM (#14695816)
That's cool, but I feel like you're unlikely to run into it very often in the wild? The vast majority of Linux systems come with ruby/perl out of the box. Plus if Python did support this sort of hackery it would quickly garner most of the bad press Perl has over the years :'(
Re:Skip grep, use awk by bobpaul on Monday July 10, 2017 @07:39PM (#14740532)
Who cares? It's on pypi (https://pypi.python.org/pypi/pyp/2.11) so just `pip install pyp` and then you have it. You're probably not going to want to distribute shell scripts that rely on pyp, but if you're distributing scripts you can just distribute scripts written entirely in Python and use pyp for your own one-liners.
Re:Skip grep, use awk by tyingq on Tuesday July 04, 2017 @09:41AM (#14695805)
The lack of something like Perl/Ruby's -n and -p switches is a barrier as well. Those are handy because they automatically work for either piped input, or files named on the command line.

Of course, you can do all of this in Python, just not as a one liner.

Re:Skip grep, use awk by geophile on Tuesday July 04, 2017 @10:22AM (#14696031)
Re:Skip grep, use awk by prathiks on Tuesday July 04, 2017 @12:14PM (#14696670)
so is the intention to be python equivalent of awk