expanding a variable
Sean 'Shaleh' Perry
shaleh at valinux.com
Thu Mar 22 16:25:45 EST 2001
On 22-Mar-2001 Jonathan Soons wrote:
>
> I am trying to give my cv group (who all have logins like cv???.)
> all the same .profile. The variable in the last line of the script
> doesn't seem to be expanding, even though this is very similar to
> an example in "Core Python Progr..."
>
>
> d = commands.getoutput('ls /u')
> dirs = string.split(d, '\n')
> for dir in dirs:
> if re.search('^cv', dir):
> os.system('cp /u/test/.profile /u/dir/')
> ^^^
os.system('cp /u/test/.profile /u/%s/' % dir)
python does not expand variables in strings.
More information about the Python-list
mailing list