You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
subprocess: call([arg, arg2], shell=True) vs call(arg+" "+arg2, shell=True) #52187
If by "fail" you mean "doesn't execute the command in the way I expected", then I believe you will be enlightened by reading the recent updates to the Popen documentation (see bpo-6760).
I can't see changes to subprocess.call() docs in issue bpo-6760. I reopen this bug, because call() definitely need a visible note about this significant behavior. I can not reopen bpo-6760
I still do not agree. There should be a note in call() documentation, because users will waste their time experiencing the bug before reading documentation again.
If you can't make something just work without rereading the whole doc - that's not pythonic.
I think given that we say the calls are shortcuts, and that their arguments are the same as Popen, I take that to mean that subprocess.call experiences the same situations as subprocess.Popen.
If any change has to be made, I could get on board with changing "two shortcut functions" to "two Popen shortcut functions".
You can't even use call or check_call without referencing the Popen constructor documentation, so I'm not sure what you are advocating, Anatoly. We certainly don't want to repeat the Popen documentation in full for each convenience function, and if we aren't doing that it seems to me that the current one line redirect to the full Popen docs is the right thing to do. I have, however, turned those references into active links. so that all you have to do is click on Popen to get bounced up to the full docs. (Change made in trunk in r78206, it will get copied to the other branches eventually.)
techtonik commented on Feb 16, 2010
techtonikmannequin
MannequinAuthor
More actions
Thanks. That should be enough, although I wouldn't mind against more prominent notice to urge users to go and see Popen parameters. I would also add a second example to allow users see the difference. For instance, how to execute another Python script:
And there are examples of that call format in the Popen docs, as well as the explanation of exactly how to format the list correctly. So again, I don't think it is a good idea to try to duplicate that in the call/check_call docs.
techtonik commented on Feb 17, 2010
techtonikmannequin
MannequinAuthor
More actions
You are right - I should read the docs, but one of the outstanding features of Python is that in many cases you can test the code faster than read documentation. =) It would help if ["ls", "-la"] example included third argument thus fully covering the concept.
Activity
techtonik commentedon Feb 16, 2010
subprocess.call([arg, arg2], shell=True) is different from subprocess.call(arg+" "+arg2, shell=True)
The last one executed correctly, the first one fails on Python 2.5.2 Debian Lenny. Why these should be different? Seems like a bug to me.
bitdancer commentedon Feb 16, 2010
If by "fail" you mean "doesn't execute the command in the way I expected", then I believe you will be enlightened by reading the recent updates to the Popen documentation (see bpo-6760).
techtonik commentedon Feb 16, 2010
I can't see changes to subprocess.call() docs in issue bpo-6760. I reopen this bug, because call() definitely need a visible note about this significant behavior. I can not reopen bpo-6760
http://docs.python.org/library/subprocess.html#convenience-functions
briancurtin commentedon Feb 16, 2010
"The arguments are the same as for the Popen constructor"
subprocess.call uses subprocess.Popen, so you should refer to Popen and it's examples for specifics.
techtonik commentedon Feb 16, 2010
I still do not agree. There should be a note in call() documentation, because users will waste their time experiencing the bug before reading documentation again.
If you can't make something just work without rereading the whole doc - that's not pythonic.
briancurtin commentedon Feb 16, 2010
"This module also defines two shortcut functions"
I think given that we say the calls are shortcuts, and that their arguments are the same as Popen, I take that to mean that subprocess.call experiences the same situations as subprocess.Popen.
If any change has to be made, I could get on board with changing "two shortcut functions" to "two Popen shortcut functions".
bitdancer commentedon Feb 16, 2010
You can't even use call or check_call without referencing the Popen constructor documentation, so I'm not sure what you are advocating, Anatoly. We certainly don't want to repeat the Popen documentation in full for each convenience function, and if we aren't doing that it seems to me that the current one line redirect to the full Popen docs is the right thing to do. I have, however, turned those references into active links. so that all you have to do is click on Popen to get bounced up to the full docs. (Change made in trunk in r78206, it will get copied to the other branches eventually.)
techtonik commentedon Feb 16, 2010
Thanks. That should be enough, although I wouldn't mind against more prominent notice to urge users to go and see Popen parameters. I would also add a second example to allow users see the difference. For instance, how to execute another Python script:
techtonik commentedon Feb 16, 2010
The last one should be:
retcode = call([sys.executable, "diff.py oldfile newfile"])
bitdancer commentedon Feb 16, 2010
I think you should reread the Popen docs carefully :)
That example should be:
And there are examples of that call format in the Popen docs, as well as the explanation of exactly how to format the list correctly. So again, I don't think it is a good idea to try to duplicate that in the call/check_call docs.
techtonik commentedon Feb 17, 2010
You are right - I should read the docs, but one of the outstanding features of Python is that in many cases you can test the code faster than read documentation. =) It would help if ["ls", "-la"] example included third argument thus fully covering the concept.