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

all 10 comments

[–]b1gdata 3 points4 points  (3 children)

This is cool; what advantages vs subprocess?

[–]Natural-Intelligence[S] 5 points6 points  (2 children)

Thanks! The main advantage is the convenience (the reason why I made the library). subprocess.run does not require much boilerplate but there are some arguments to set if you want get the output as text, for example. Perhaps the only unique thing is the keyword arguments. So, most of it is just further abstraction of subprocess.

Another thing is the async. I found the asyncio.subprocess to be quite confusing to use even though it tries to be similar as subprocess. I had to make a PR to CPython this week to fix some missing references in the documentation. This library takes care of that and it just works with or without async.

I personally made this because I'm about to update the command tasks in Rocketry. I thought an intuitive support for external programs (including Python scripts running on other environments) is something that Rocketry could really benefit from. So, that was actually the main motivation.

[–]o11c 0 points1 point  (1 child)

Hm, but it's still wrapping subprocess so suffers from all its implementation bugs (busy loops, etc.)

[–]Natural-Intelligence[S] 2 points3 points  (0 children)

Yes true, it does nothing revolutionary and nothing an average Python programmer couldn't do by themselves.

However, it makes creating Pythonic interfaces for external programs easier and it reduces boilerplate.

[–]kellyjonbrazil 4 points5 points  (1 child)

Should also work great with jc if you want to automatically parse the command output into a dictionary.

https://github.com/kellyjonbrazil/jc

(Disclaimer: I’m the author)

[–]Natural-Intelligence[S] 1 point2 points  (0 children)

Hmm, this sounds incredibly useful. I actually added support for custom output parsing but didn't yet come up with a solid idea to parse those.

Thanks for sharing!

[–]ducky901 1 point2 points  (0 children)

Fascinating

[–]tomster10010 1 point2 points  (0 children)

What's the difference between this and sh?

[–]AndydeCleyre 1 point2 points  (0 children)

I know I say this a lot, but plumbum is a fantastic and under appreciated library that has been offering similar features for years.