Windows - Need to process quotes in string...

E

Ernesto

I'm trying to use a $ delimeter, but it doesn't seem to work. Here is
the code:


launchWithoutConsole("devcon.exe",d'$enable
"@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"$)

I want to send the string parameter:

enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"

to the program devcon.

The argument itself is a string, but has quotes inside too. I've tried
it many different ways and I keep getting syntax errors.

Thanks,
 
S

Sybren Stuvel

Ernesto enlightened us with:
I'm trying to use a $ delimeter
Why?

I want to send the string parameter:

enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"

launchWithoutConsole("devcon.exe"
'enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"')

Or, if you should also be able to send single quotes:

launchWithoutConsole("devcon.exe"
'''enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"''')
The argument itself is a string, but has quotes inside too.

Then use other quotes as string delimiters. Why would you use
something else?

Sybren
 
F

Francesco Bochicchio

Il Mon, 31 Oct 2005 07:18:31 -0800, Ernesto ha scritto:
I'm trying to use a $ delimeter, but it doesn't seem to work. Here is
the code:


launchWithoutConsole("devcon.exe",d'$enable
"@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"$)

I want to send the string parameter:

enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"

to the program devcon.

The argument itself is a string, but has quotes inside too. I've tried
it many different ways and I keep getting syntax errors.

Thanks,

Use the single quote to delimit the string, so you can use the double
quote inside it. Like this:

'enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"'

Ciao
 
T

Tim Roberts

Ernesto enlightened us with:
Where did you get the idea that this would work? I can't find any
references to a "customizable string delimiter" in any Python up through
2.4.2. I recall it being proposed at one point, but I don't think it was
ever seriously considered.

Sybren Stuvel said:
launchWithoutConsole("devcon.exe",
'enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"')

This is not correct. It might accidentally work because \V is not a
defined escape sequence, but the right answer is either:

launchWithoutConsole("devcon.exe",
'enable "@USB\\VID_0403&PID_6010&MI_00\\7&15E4F68&1&0000"')

or

launchWithoutConsole("devcon.exe",
r'enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000"')

However, devcon.exe supports regular expressions, and is forgiving about
syntax. If you have only one such device, you could use:

launchWithoutConsole("devcon.exe",
r'enable "@USB\VID_0403&PID_6010*"')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top