4 ms·
Hey, it would be awesome to have something like this for Python!
by d33 9y ago
Hey, it would be awesome to have something like this for Python!
- Ultimatt 9y agoNot 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.
- phaemon 9y agoThere is "Pyed Piper" aka `pyp` https://code.google.com/archive/p/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."
- Ultimatt 9y agoThat'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 :'(
- bobpaul 9y agoWho cares? It's on pypi (https://pypi.python.org/pypi/pyp/2.11 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.
- tyingq 9y agoThe 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.
- deleted 9y ago[deleted]
- gmfawcett 9y agoI 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-like-sed-like-command-line-tool/ https://code.activestate.com/recipes/437932-pyline-a-grep-li...
- edraferi 9y agoThat's pretty cool, thanks!
- geophile 9y agoCheck out osh: https://github.com/geophile/osh https://github.com/geophile/osh
- prathiks 9y agoso is the intention to be python equivalent of awk