a question

Bill Mill bill.mill at gmail.com
Wed Jan 19 15:51:26 EST 2005


Nader,

You've got a couple problems. First, you need to end the string before
putting a continuation in. Secondly, you have 6 variables to be
substituted and only provide 4. Here's some code, edited to show how
to use continutations to join strings:

>>> mosbin, jaar, filetype = (1,1,1)
>>> cmd = '%s/mos user wmarch, cd /fa/wm/%s/%s, mkdir %s, put %s'\
... '%s' % (mosbin, jaar, filetype, filetype, filetype, filetype)
>>> cmd
'1/mos user wmarch, cd /fa/wm/1/1, mkdir 1, put 1, chmod 6441'

Peace
Bill Mill
bill.mill at gmail.com

On Wed, 19 Jan 2005 16:16:32 +0000, Nader Emami <emami at knmi.nl> wrote:
> L.S.,
> 
> I have a long command in Unix and I have to use os.system(cmd)
> statement. I do the following:
> 
> cmd = '%s/mos user wmarch, cd /fa/wm/%s/%s, mkdir %s, put %s, chmod 644
> %s' % (mosbin, jaar, filetype, filetype)
>      status = os.system(cmd)
> 
> This is not very clear, and I have to break this long line in two
> segment by means of the next character '\' :
> cmd = '%s/mos user wmarch, cd /fa/wm/%s/%s, mkdir %s, put %s, \
>         chmod 644 %s' % (mosbin, jaar, filetype, filetype)
> 
> But in this case I get a syntax error! I don't know how I can solve this
> problem. Could somebody tell me about this?
> 
> With regards,
> Nader
> 
>   (this
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list