String operations
Terry Hancock
hancock at anansispaceworks.com
Sat Dec 11 01:52:34 EST 2004
On Wednesday 01 December 2004 04:20 pm, Anoop Rajendra wrote:
> os.execvp("condor_q",["condor_q","-l","-constraint",'"ProjectId==\\\"anoopr_samadams.fnal.gov_161903_30209\\\""'])
>
> doesnt work. Its definately a problem with one of the million
> backslashes and quotes present, but I'm not able to figure it out.
> What am I doing wrong?
Honestly, I'm not sure, but try the following:
1) Paste the questionable string onto a print statement (in the
interactive interpreter), and get python to tell you what it made
of what you wrote:
print '"ProjectId==\\\"anoopr_samadams.fnal.gov_161903_30209\\\""'
2) Try using a "raw string", which won't try to interpret the backslashes:
r'''"ProjectId==\"anoopr_samadams.fnal.gov_161903_30209\""'''
3) Use triple-quotes (as I did above) instead of escaping your quotation
marks: in Python you can actually quote with 'a', "a", '''a''', or """a""". The
triple quotes interpret newlines literally, but they also interpret both
single and double quotation marks as literal characters, which can be
convenient.
That should get you there with a little tinkering.
Cheers,
Terry
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com
More information about the Python-list
mailing list