newbie variables question

Alex Martelli aleaxit at yahoo.com
Sat Mar 31 02:22:01 EST 2001


"Michael Hall" <py.list at mulga.com.au> wrote in message
news:mailman.986005960.10805.python-list at python.org...
>
> I've been trying to do this:
>
> SYSPRODIR = /home/admin/systemprofile
> os.system('mv /tmp/install.log SYSPRODIR/install.log')
>
> No matter how I play around with single and double quotes, this won't
> work.
>
> But this does work:
>
> os.system('mv /tmp/install.log %s/install.log' %s SYSPRODIR)
>
> Is this the normal/best way to do this in Python ... seems a little
> convoluted me, like there must be a simpler way. Bash for example would be

There are several ways, but I think this one is simplest.  Alternatives:

os.system('mv /tmp/install.log '+SYSPRODIR+'/install.log')
os.system('mv /tmp/install.log %(SYSPRODIR)s/install.log' % vars())
os.system('mv /tmp/install.log FOO/install.log'.replace('FOO',SYSPRODIR))


Alex







More information about the Python-list mailing list