Re:Piep: bringing the power of python to stream editing
by gfxmonk on Wednesday March 28, 2012 @09:42PM
(#3769267)
It's inspired by a similar tool called `pyp`, which I considered extending but ended up going my own route instead. Here's some more information on why: http://gfxmonk.net/2012/03/28/why-piep.html
Re:Piep: bringing the power of python to stream editing
by cibot on Thursday March 29, 2012 @01:41AM
(#3769794)
Yep. Now i need to go after another packaging tool to try it out. Well not a big deal.. However imho it would be awesome if everyone stick with the standard tools.
Re:Piep: bringing the power of python to stream editing
by gfxmonk on Thursday March 29, 2012 @01:50AM
(#3769810)
You absolutely can use `pip`, if you want. I made sure of that (or at least tested it once), because I know it's widely used and convenient. But I personally think it's a terrible way to install and distribute software, and would love for more people to try Zero Install, because I think it's the way that software ought to be distributed.
Re:Piep: bringing the power of python to stream editing
by gfxmonk on Thursday March 29, 2012 @01:41AM
(#3769793)
somewhat, although that seems fairly heavily geared towards clusters of machines, which I've not really tried to address with piep. I've used gnu-parallel and cluster-ssh in the past for that sort of thing, though I'd likely prefer a pythonic way of doing it.
Re:Piep: bringing the power of python to stream editing
by berntb on Thursday March 29, 2012 @04:54AM
(#3770336)
Why not just bite the bullet and add optional {}:s to Python instead, so you don't have to learn a tool just to get normal command line (/oneliner) usability?
The total sum of complexity to learn/use would be about the same (and Python would get multi instruction anon funs.)
Re:Piep: bringing the power of python to stream editing
by gfxmonk on Thursday March 29, 2012 @07:31AM
(#3770619)
The thing about piep (and other such tools) is that they can make some reasonable assumptions that would typically be a bad choice for a generic language - things like having global variables for commonly used items, making assumptions about how certain return values should be interpreted, etc. Small things like this wouldn't fit well with most general programming languages, with the possible exception of perl.
Plus, it still doesn't solve the piping issue. constructing a command as a sequence of operations like:
p.foo() | len(p) | p + 1 | str(p)
is much easier to follow (and modify) than
str(len(p.foo()) + 1)
this is not a big deal for programming languages because we use variables, functions and other ways of structuring our code, but those don't map well to oneliners.
Re:Piep: bringing the power of python to stream editing
by icebraining on Thursday March 29, 2012 @05:12AM
(#3770378)
Python one-liners are already possible using ;
python -c 'import sys; a = int(sys.stdin.readline())) ; print(range(a))'
EDIT: Not that I'm saying piep is useless; far from it, it seems very interesting. I'm saying that optional {}s wouldn't solve the problem that piep is trying to solve.
Re:Piep: bringing the power of python to stream editing
by berntb on Thursday March 29, 2012 @08:40AM
(#3770800)
Yes, but my point was: How do you add an if to that Python code... or anything else dependent on Python indentation?
Another example: map {} is better than having to learn weird single instruction variants like list comprehensions. And so on.
In this case, it is easy to have a shell alias that loads a module and executes its parameter in any other language. Then you have any piep functionality not already built in. Ergo, no need for extra things to learn, in those languages.
Re:Piep: bringing the power of python to stream editing
by michaelmior on Thursday March 29, 2012 @01:02PM
(#3771938)
You add an if using the ternary style syntax. i.e. "if foo then bar else baz". I think that's sufficient for what piep is trying to do. I can't imagine trying to do anything else with indentation that couldn't be accomplished with list comprehensions.
Re:Piep: bringing the power of python to stream editing
by michaelmior on Thursday March 29, 2012 @01:20PM
(#3772031)
piep seems to be designed for quick processing on the command line. If you want to do something especially complicated, you can (and probably should) write a separate script for it.
The total sum of complexity to learn/use would be about the same (and Python would get multi instruction anon funs.)
Plus, it still doesn't solve the piping issue. constructing a command as a sequence of operations like:
p.foo() | len(p) | p + 1 | str(p)
is much easier to follow (and modify) than
str(len(p.foo()) + 1)
this is not a big deal for programming languages because we use variables, functions and other ways of structuring our code, but those don't map well to oneliners.
Another example: map {} is better than having to learn weird single instruction variants like list comprehensions. And so on.
In this case, it is easy to have a shell alias that loads a module and executes its parameter in any other language. Then you have any piep functionality not already built in. Ergo, no need for extra things to learn, in those languages.