0

I have a long long command to send over SSH using Paramiko and I need to wrap the string using "r" parameter but the IDE still tells me it's not written fine. The string is something like that:

somecommand get -n somestuff sa/management --template='{{range .secrets}}{{printf "%s\n" .name}}{{end}}'

I tried doing:

command = r'somecommand get -n somestuff sa/management --template='{{range .secrets}}{{printf "%s\n" .name}}{{end}}'

But got an error. This is probably something super easy to do....

1
  • What kind of template code is this? It's very hard to guess how this \n will finally be rendered. Especially without an error message. It's also strange that your error didn't come with an error message. Commented Jun 12, 2016 at 12:24

1 Answer 1

2

First, you are missing a quote at the end of your string. The second problem is that you can't use quotes inside a string like that.

r'some'thing'

won't work while

r'some"thing'

will work. Since you have quotes in quotes inside the string use a triple-quoted string instead:

r"""some"thi'ng"""

So a working version of your string would be:

command = r"""somecommand get -n somestuff sa/management --template='{{range .secrets}}{{printf "%s\n" .name}}{{end}}'"""
Sign up to request clarification or add additional context in comments.

1 Comment

Brilliant, mate! Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.