Re:Plumbum: Pythonic Shell Combinators
by friggeri on Saturday May 12, 2012 @07:40PM
(#3965541)
Someone needs to explain to me in what parallel universe
is more readable than
[ Parent
| on HN ]
It's not. The reasons that one might use `plumbum` are similar to the reasons that one might use `fabric` instead of just running local/remote shell scripts, i.e.
- Ability to leverage the richness of Python to pre/post-process the inputs/outputs from other shell commands.
- Easier to parameterise and maintain.
- Familiarity with Python over the likes of bash, zsh, etc.
Em, the fabric version would be much more readable I'm not mistaken:
local("ls - l | grep foo")
From looking at the code it seems like plumbum is more object oriented, instead of having stuff like https://github.com/fabric/fabric/blob/master/fabric/state.py... in fabric, so thats a good move forward.
Re:Plumbum: Pythonic Shell Combinators
by cheatercheater on Sunday May 13, 2012 @06:28AM
(#3966620)
Yes, because OOP is salvation. Right?
Right, lol.
Re:Plumbum: Pythonic Shell Combinators
by sirclueless on Saturday May 12, 2012 @08:00PM
(#3965577)
It's definitely not, until you need to access the stdout of that command programmatically. Plumbum replaces the subprocess module (and os.system etc.), not shell scripts, despite their motto. It might displace shell scripts, because once you can use lists, maps, functions with actual arguments, etc. why would you go back? But it's not going to replace shell one-liners any time soon.
Re:Plumbum: Pythonic Shell Combinators
by tomerfiliba on Sunday May 13, 2012 @04:20AM
(#3966363)
you probably didn't want the "& FG" part, as it would go to the screen and run "in the foreground", e.g., make you wait. but anyway, as other people have said, it aims at providing an object oriented replacement for shell scripts, etc.
This is not an object-oriented replacement for shell scripts. This is a shell script DSL embedded in Python.
If you want to use Python to manipulate the input or output of shell commands, then write a Python script that reads from stdin and writes to stdout, and use the shell to insert that script into the appropriate point in your command chain. It's the UNIX way.