files,folders,paths

ecu_jon hayesjdno3 at yahoo.com
Mon Feb 14 01:25:26 CET 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.
http://thanksforallthefish.endofinternet.net/testing.py
the output looks like
....
folder to copy =  \\\\Mothera\\jon\week2
file to copy: C:\Users\jon\backup\configs\apache2.conf \\\\Mothera\\jon
\week2\configs\apache2.conf
folder to copy =  \\\\Mothera\\jon\week2\configs
....#some lines ommited for brevity.



More information about the Python-list mailing list