Hacker News new | past | comments | ask | show | jobs | submit login

Is there an easy way to run shell commands in Python, like backticks in PERL, Ruby or even PHP?

I'd really like to use Python more often, but most of the time it only complicates things with those verbose syscalls.




IPython. Seems to work for simple stuff like `ls blah`, but I'm not aware how far this stretches, and is probably not super safe to use.

EDIT: Seems I've only tried too basic things - it works thanks to %automagic, and seemingly %man is a thing. Other option is to use %%sh or %%bash, but that's a bit verbose.


Check out python sh: https://github.com/amoffat/sh


>sh.ls("-l", "/tmp", color="never")

Nope. I really need to be able to test commands on the terminal and then copy/paste them without any modifications. I won't even try to get used to that stupid syntax.


Unfortunately not. I have used Ruby a little bit and that is really nice feature.


part of the complication is due to actually having the proper data seperation that you need to jump through hoops to get in bash. If you go with backtick style calls you lose a lot of that.





Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: