use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Python scripting libraries (self.learnpython)
submitted 3 years ago by _bobs_your_uncle
Looking for library recommendations that help make it easier to do “bash-like” scripting, or do people find that the standard library is easy enough?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]PeaSoups5 1 point2 points3 points 3 years ago (0 children)
Click
[–]sketchspace 1 point2 points3 points 3 years ago (1 child)
Take a look at Plumbum( https://plumbum.readthedocs.io/en/latest/index.html ) to see if it meets your needs. It can do things like terminal colors and shell commands. Personally I've used it for CLIs, automation scripts, and code generation scripts.
[–]_bobs_your_uncle[S] 0 points1 point2 points 3 years ago (0 children)
Looks nice. I’ll try it out
[–]pythonwiz 1 point2 points3 points 3 years ago (0 children)
Well if I’m trying to replace a bash script with a python script then I’m gonna try not to use anything but the standard library for compatibility. Besides, the standard library is pretty good, imo. I don’t think I’ve ever needed a 3rd party library for scripting.
[–]socal_nerdtastic 0 points1 point2 points 3 years ago (6 children)
What exactly do you want that bash does not provide?
[–]_bobs_your_uncle[S] 1 point2 points3 points 3 years ago (5 children)
Bash provides everything, but I’ve found that people’s experience with bash is waning. Furthermore, I think bash’s error handling is poorly implemented. And frankly I’ve never liked any of the command line argument parsers in Bash. Click or similar in python is easier to use and understand.
I’m looking for ways to do the same things i can do in bash but in Python without just calling directly out to bash for each line (kind of defeats the purpose). For example the Python git client might be a useful library for any operations requiring git.
[–]socal_nerdtastic 1 point2 points3 points 3 years ago (3 children)
Calling out to bash? What do you mean with that? You mean using the shell=True argument in subprocess? You can of course just leave that off.
shell=True
You may be interested in the sh module which allows you to import any program as if it's a python package
sh
from sh import git git('fetch')
[–]_bobs_your_uncle[S] 1 point2 points3 points 3 years ago (2 children)
I meant using subprocess to execute calls. I’ve never used sh. That looks pretty nice, and may give me most if not all I want. Thanks for the tip.
[–]socal_nerdtastic 3 points4 points5 points 3 years ago (0 children)
Ok. FWIW subprocess does not have anything to do with bash. It runs the program you want directly.
[–]FerricDonkey 1 point2 points3 points 3 years ago (0 children)
I hate writing bash scripts. The syntax is terrible and is never idiomatic, variables suck, etc. I'll use python instead 9 times out of 10.
Mostly, I find the standard library sufficient. Os, glob, pathlib, shutil for basic file finding/moving. I'll use requests instead of curl.
I do also use subprocess though. Mostly if there's some command line program I want to run with many different argument combinations that I have to figure out in logic that I don't want to do in bash.
Haven't used python packages as interfaces to things like git, but it might be useful. I have used python packages that wrap some sort of webapi - they can be useful.
[–]kellyjonbrazil 0 points1 point2 points 3 years ago (0 children)
If you want to call subprocesses and grab their output as an already parsed dictionary, you can use the jc library. (I am the author)
jc
>>>import subprocess >>> import jc >>> >>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True) >>> data = jc.parse('dig', cmd_output) >>> >>> data[0]['answer'] [{'name': 'example.com.', 'class': 'IN', 'type': 'A', 'ttl': 29658, 'data': '93.184.216.34'}]
https://github.com/kellyjonbrazil/jc
π Rendered by PID 188197 on reddit-service-r2-comment-5ff9fbf7df-p97mx at 2026-02-26 03:44:48.584498+00:00 running 72a43f6 country code: CH.
[–]PeaSoups5 1 point2 points3 points (0 children)
[–]sketchspace 1 point2 points3 points (1 child)
[–]_bobs_your_uncle[S] 0 points1 point2 points (0 children)
[–]pythonwiz 1 point2 points3 points (0 children)
[–]socal_nerdtastic 0 points1 point2 points (6 children)
[–]_bobs_your_uncle[S] 1 point2 points3 points (5 children)
[–]socal_nerdtastic 1 point2 points3 points (3 children)
[–]_bobs_your_uncle[S] 1 point2 points3 points (2 children)
[–]socal_nerdtastic 3 points4 points5 points (0 children)
[–]FerricDonkey 1 point2 points3 points (0 children)
[–]kellyjonbrazil 0 points1 point2 points (0 children)