one command on backslash and space for review

Ian Kelly ian.g.kelly at gmail.com
Sun Jul 10 13:41:28 EDT 2016


On Sun, Jul 10, 2016 at 9:19 AM, Ganesh Pal <ganesh1pal at gmail.com> wrote:
> Hello Team,
>
> I am on python 2.7 and  Linux , I  want to  form the below sample
> command so that I could run it on the shell.
>
> Command is --> run_parallel -za1 -s 'daemon -cf xyz; sleep 1'
>
> Here is how I formed the command and it seems to look fine and work
> fine , but I think it could still be better any idea ?
>
>>>> cmd = "run_parallel -za" + str(number) + \
> ...       " -s" + " \'daemon -cf xyz; sleep 1\'"

cmd = "run_parallel -za{} -s 'daemon -cf xyz; sleep 1'".format(number)

> Looking for thoughts around:
>
> 1. If backslash are syntactically  correct

They're correct, but using them before single quotes in a string
delimited by double quotes is unnecessary.

> 3. Iam running sleep command on the cluster i.e , how could I make it
> look Python or its fine to have sleep ?

I don't understand the question.



More information about the Python-list mailing list