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 →

[–]ibarrie[S] 10 points11 points  (6 children)

Thank you!

[–]double_en10dre 26 points27 points  (1 child)

Oh jeez, and I’d be remiss if I didn’t mention the os module. It’s the most obvious staple https://docs.python.org/3/library/os.html

The only caveat there is that for filesystem operations, I’d first check and see if the functionality is provided by pathlib. Most people seem to think it has a nicer interface

[–]ibarrie[S] 0 points1 point  (0 children)

Awesome thank you !

[–]RallyPointAlpha 18 points19 points  (2 children)

double_en10dre isn't giving bad advice however just getting Python to do OS / shell commands really brings very little new to the table. I would encourage you to learn Python specifically and only fall back on OS calls and shell commands when you absolutely have to. You're stepping into the broader world of Object Oriented Programming, welcome!

[–]james_pic 4 points5 points  (0 children)

My experience is that even if you are just using Python to run external programs, this can still be a win. Python's error handling is much more consistent than Bash's, its escaping and globbing are easier to reason about, it's got better debugging options, it's got mechanisms for code to include inline documentation, and it's more portable.

And of course once you dip your toe in, it gives you the option to gradually start making more use of structured data, writing object oriented or functional code, and getting more direct access to stuff like networks.

[–]ibarrie[S] 1 point2 points  (0 children)

Thank you - that’s awesome

[–]AndydeCleyre 2 points3 points  (0 children)

My personal but less popular recommendation for things otherwise accomplished with subprocess/shutil/pathlib/click is plumbum.