[Tutor] simply moving files]]
David
david at abbottdavid.com
Wed May 13 10:40:05 CEST 2009
Alan Gauld wrote:
>
> "David" <david at abbottdavid.com> wrote
>
>> Forwarded to the list, I would also like to understand the forward slash;
>> os.system("mv %s/%s %s" % (src, fnames, dst))
>
> The slash separates the file path, src, from the filename.
>
> Thus if src is /foo/bar/baz
> and fnames is spam
>
> then %s/%s becomes
>
> /foo/bar/baz/spam
>
> Another way of doing the same thing would be with join:
>
> '/'.join([src,fnames])
>
> or for platform independance:
>
> os.sep.join([src,fnames])
>
> HTH,
>
Thank you Alan, you are a very good teacher, you should write a book :)
--
Powered by Gentoo GNU/Linux
http://linuxcrazy.com
More information about the Tutor
mailing list