>
> From: Oscar Benjamin
>To: Albert-Jan Roskam
>Cc: Dave Angel ; eryksun ;
>"Tutor@python.org"
>Sent: Wednesday, February 26, 2014 3:38 PM
>Subject: Re: [Tutor] subprocess.call list vs. str argument
>
>
>On 26 Febru
On 26 February 2014 08:50, Albert-Jan Roskam wrote:
>
> Yesterday evening (it was *late* so forgive me if I wrong) I realized that
> part of my confusion was also caused by the fact that I ran my code in Idle.
> If I called subprocess.call with a list argument, it returned code 0
> (success) bu
On Wed, Feb 26, 2014 at 3:50 AM, Albert-Jan Roskam wrote:
> On Tue, Feb 25, 2014 at 4:54 PM, Dave Angel wrote:
>> CreateProcess has its own design bobbles as well. For
>> example, if you forget to put quotes around the program
>> name, it will happily try to add ".exe" to *multiple*
>> places in
?
~~
On Tue, 2/25/14, eryksun wrote:
Subject: Re: [Tutor] subprocess.call list vs. str argument
To: "Dave Angel"
Cc: tutor@python.org
Date: Tuesday, February 25, 2014, 11:30 PM
O
On Tue, Feb 25, 2014 at 4:54 PM, Dave Angel wrote:
> CreateProcess has its own design bobbles as well. For example, if
> you forget to put quotes around the program name, it will
> happily try to add ".exe" to *multiple* places in the hopes that
> one of them will work.
>
> Adding a file c:\prog
eryksun Wrote in message:
>
>
> FYI, in Windows the situation is different. CreateProcess takes a
> string argument, so the setup code changes to the following:
>
>
> It's fine to use a string for args in Windows, and you may need to if
> the program parses the command line differently than l
See the comment about 'args' in:
http://docs.python.org/2/library/subprocess.html#frequently-used-arguments
which says:
"""args is required for all calls and should be a string, or a
sequence of program arguments. Providing a sequence of arguments is
generally preferred, as it allows the mod
On Tue, Feb 25, 2014 at 2:52 PM, Albert-Jan Roskam wrote:
> Here is why I used "shell=True" before. Is it related to the
> file paths?
>
> cmd = (r'sphinx-apidoc '
>r'-f -F '
>r'-H "%(title)s" '
>r'-A "%(author)s" '
>r'-V "%(version)s" '
>
Albert-Jan Roskam Wrote in message:
>
>
> - Original Message -
>
>> From: Danny Yoo
>> To: Peter Otten <__pete...@web.de>
>> Cc: Python Tutor Mailing List
>> Sent: Monday, February 24, 2014 11:01 PM
>> Subject: Re: [Tutor] subproces
- Original Message -
> From: Danny Yoo
> To: Peter Otten <__pete...@web.de>
> Cc: Python Tutor Mailing List
> Sent: Monday, February 24, 2014 11:01 PM
> Subject: Re: [Tutor] subprocess.call list vs. str argument
>
> Last comment (apologies for being so frag
Last comment (apologies for being so fragmented!). I don't know why
the literal strings there are raw there. Altogether, I'd expect:
#
cmd1 = ['sphinx-apidoc',
'-f',
'-F',
'-H', title,
'-A', author,
'-V', version,
There are a few issues there. I'd also recommend not trying to
shell-quote these manually,
# in the argument list of os.subprocess:
r'-H', '"%s"' % title,
r'-A', '"%s"' % author,
r'-V', '"%s"' % version,
Rather, just do the simpler thing:
r'-H', title,
r'-A', author,
Peter Otten wrote:
>> r'-f -F',
>> r'-H', '"%s"' % title,
>
> "title" becomes \"title\", i. e. Python puts in an extra effort to have
> the quotes survive the subsequent parsing process of the shell:
>
print subprocess.list2cmdline(['"title"'])
> \"title\"
Forget that :(
Danny spotted th
Albert-Jan Roskam wrote:
> Hi,
>
> In the code below, cmd1 and cmd2 are equivalent, as in: " ".join(cmd1) ==
> cmd2. But the first example returns a code 2, whereas the second runs
> successfully. What is the difference? I prefer using a list as it looks a
> little cleaner. Btw, shell=True is nee
> cmd1 = [r'sphinx-apidoc',
>r'-f -F',
This part looks suspicious. Are you sure you don't mean:
'-f', '-F'
here? They need to be separate arguments.
Also, you mention:
> Btw, shell=True is needed here.
Why do you need shell expansion on the arguments? This can be
dangerous u
Hi,
In the code below, cmd1 and cmd2 are equivalent, as in: " ".join(cmd1) == cmd2.
But the first example returns a code 2, whereas the second runs successfully.
What is the difference? I prefer using a list as it looks a little cleaner.
Btw, shell=True is needed here.
# Python 2.7.3 (default, J
16 matches
Mail list logo