0

I had a command in python script as below:

start_command = [
        "load=" + location + "/lib/abc " + "conf=myconf " +
        location + "/bin/mysqld "
        "--defaults-file=" + location + "/var/myfile.cnf " 
        ]

    

I want to push the second part of the code as a variable(connect_str) & concatenate in start command. but it's not working . Is this because of escape character?

 connect_str="conf=myconf " +
        location + "/bin/mysqld "
        "--defaults-file=" + location + "/var/myfile.cnf "
 start_command = [
        "load=" + location + "/lib/abc " + connect_str

3 Answers 3

1

Yes, using \ to scape \n

connect_str = "conf=myconf " + location + \
    " /bin/mysqld " "--defaults-file=" + location + \
    " /var/myfile.cnf "
Sign up to request clarification or add additional context in comments.

Comments

1

if u want concatenate str its should be str , i see a list in your code, and no escape character is this \ in your there are /. I recommend you to use format is much better like this

connect_str="conf=myconf {} /bin/mysqld --defaults-file={} /var/myfile.cnf ".format(location,location)

Comments

0

My mistake was in declaring the string variable which i changed & made it work. It was actually annotation issue due to putting in multiple lines.

connect_str="conf=myconf " + location + "/bin/mysqld " "--defaults-file=" + location + "/var/myfile.cnf "
 start_command = [
        "load=" + location + "/lib/abc " + connect_str
          ]

Is there any better way to resolve the issue rather than putting it in single line?

Comments

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.