Coder Social home page Coder Social logo

Comments (5)

gpshead avatar gpshead commented on July 17, 2024 3

The benefit of this one is that it's subprocess backed with all that brings. I agree shell=True is not what I promote use of but if we recommend people skip over os.system in favor of something else, subprocess.shell might make a good gateway drug out of os land.

os.system is, as the os module is generally intended to be, a thin wrapper around the platform's libc or platform provided system() or _wsystem() C calls.

from cpython.

zooba avatar zooba commented on July 17, 2024 2

So essentially shell = functools.partial(subprocess.run, shell=True)? That seems fine to me.

from cpython.

zooba avatar zooba commented on July 17, 2024 2

Possibly.

I think it has plenty of legitimate uses, which is why keeping os.system is important. But adding something new to support it is certainly endorsing its use. And it doesn't really have much of a place in production or library code, while it does have an important place in scripting.

It's being added here so we can soft deprecate it elsewhere. I'd rather just leave the original one in place without any kind of deprecation.

from cpython.

barneygale avatar barneygale commented on July 17, 2024 1

Are we handing beginners a foot-shotgun by making shells (and all their quoting problems) easier to access? I like the explicit subprocess.run(..., shell=True) spelling, but maybe I've stockholm syndrome'd myself.

from cpython.

gpshead avatar gpshead commented on July 17, 2024

I think that functools.partial definition is exactly all this should be (though lets make sure it does not allow shell=False to be passed - I don't recall off the top of my what functools.partial does in that situation).

Documentation wise it'd get listed in the subprocess docs after subprocess.run() with a one or two sentence description that it is just "run" with "shell=True" for convenience. With an example. And with the caveats of shell=True being re-stated.

from cpython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.