Dandroid
link
fedilink
121Y

Do you do any scripts beyond extremely simple ones?

I do a fuck ton of scripting in both bash and python. I never want to do string manipulation in bash. As soon as string manipulation is required, I automatically choose python for a script. Also, if I need named arguments or multiple levels of arguments for subcommands. You can use sys.argv for basic args, which isn’t any harder than bash arguments, but for complex inputs, argparse is a godsend. It has a bit of a learning curve, but it can handle anything. Bash requires you to write complex arg handling manually with loops and reducing.

You should check out Click. Way more user friendly than argparse imo. I agree with all of your points though, and I’d also add if you are working on a team that it will be infinitely easier for a co-worker to decipher your python code compared to a bash script. And you can write unit tests with py test, the list goes on and on. If the environment you are deploying to has the python interpreter, you should use python over bash.

Dandroid
link
fedilink
31Y

I’ll take a look at Click. Something better than argparse definitely piques my interest, because while the features are great, it feels a little cumbersome at times.

I’m trying to bash it but the problem persists. Please help.

AbsolutelyNotCats
link
fedilink
English
-31Y

deleted by creator

Tbh you’d still be better off writing them in python. They’ll be more maintainable, and you’ll learn valuable skills.

Also, since you commented that python was the slowest language ever, shell scripts are often significantly slower. This is due to the fact that shell commands are actually calling other programs, which is very very slow.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.7K Comments
  • Modlog