hayesjdno3 at yahoo.com
Sun Feb 13 19:25:26 EST 2011
On Feb 13, 6:39 pm, Ben Finney <ben+pyt... at benfinney.id.au> wrote:
> ecu_jon <hayesjd... at yahoo.com> writes:
> > can you give an example of how to build a folder name, maybe as a
> > string, with parts of it as variables, that have to be strung
> > together. like x = "//servername/+variable+"/"+variable+"/"
> import os.path
> infile_path = os.path.join(["//servername", start_dir, other_dir])
> Read the documentation for ‘os.path.join’. It's fundamental if you're
> working with filesystem paths.
> > when i did something liek that the end result string was like
> > //servername/folder/folder\file and i got an error
> That path should work on MS Windows. If you want us to comment on the
> error, you'll need to show the code here *and* the error traceback.
> \ “If this is your first visit to the USSR, you are welcome to |
> `\ it.” —hotel room, Moscow |
> _o__) |
> Ben Finney
here take a look.
the output looks like
folder to copy = \\\\Mothera\\jon\week2
file to copy: C:\Users\jon\backup\configs\apache2.conf \\\\Mothera\\jon
folder to copy = \\\\Mothera\\jon\week2\configs
....#some lines ommited for brevity.
More information about the Python-list