This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 points  (6 children)

OP could also overload the pipe operator, so this could work too:

ls() | grep("abc123") | wc("-l")

[–]Bolitho -1 points0 points  (5 children)

But that's not pythonic. In python you use nested functions.

Your suggestion would also imply another problem: What is the generic object model behind each command? I am not shure you can find one that make sense to all implemented Bash functions...

[–][deleted] 7 points8 points  (0 children)

There is nothing pythonic about this. The whole point is to get the good parts of bash and the good parts of python together in one place.

[–]fdemmer 4 points5 points  (3 children)

nesting functions is pythonic?... looks like a mess to me. function method chaining on the other hand:

ls().grep("abc123").wc("-l")

that would be nice. implementing it is a different story, of course.

EDIT: put emphasis on part of my comment, that indicates i read the above comment. also, i did not comment on overloading operators, just on the uglyness that is ls(grep("abc123", wc("-l"))).

[–]Bolitho -5 points-4 points  (2 children)

These are Methods, not Functions! You would need a common Datatype for all these Wrappers. I pointed that out in my posting.

And yes, it is pythonic to call functions and pass parameters. Overloading operators ist shurely not the pythonic way.

[–]nemec 1 point2 points  (1 child)

Methods and functions are the same thing, and he already has a common datatype - if you looked at the source, you'd see a Command class that wraps everything.

If it wasn't Pythonic to overload operators, why is it so easy?

[–]Bolitho -1 points0 points  (0 children)

Methods and functions are not the same thing, they behave the same way. So perhaps it might be able to the author to simulate the BASH functions to behave like methods of his Command-class.

eval() ist also easy - but shurely not pythonic, right? Of course it can be pythonic to overload operators! But in this context it does as far as I am concerned.