homedir, file copy
rantingrick
rantingrick at gmail.com
Sun Jan 30 18:36:13 EST 2011
On Jan 30, 5:13 pm, ecu_jon <hayesjd... at yahoo.com> wrote:
> what does this mean? Use os.path.join(x,y, z*)
> what is the x,y,z?
x,y, and z in this case are just generic variables. Consider x+y=10. x
and y could both equal 5 or any number of combinations of two numbers
who sum equals ten. Anyway see the link chris posted to the docs or
fire up your python shell and try this...
>>> import sys
>>> sys.version_info
(2, 6, 5, 'final', 0) # yours may be different!
>>> folder = 'C:/some\\\\path/to/folder'
>>> filename = 'somefile.txt'
>>> import os
>>> help(os.path.join)
Help on function join in module ntpath:
join(a, *p)
Join two or more pathname components, inserting "\" as needed.
If any component is an absolute path, all previous path components
will be discarded.
>>> os.path.join(folder, filename)
'C:/some\\\\path/to/folder\\somefile.txt'
>>> help(os.path.normpath)
Help on function normpath in module ntpath:
normpath(path)
Normalize path, eliminating double slashes, etc.
>>> os.path.normpath(os.path.join(folder, filename))
'C:\\some\\path\\to\\folder\\somefile.txt'
psst: i know what you're thinking... and yes, python is very cool!
More information about the Python-list
mailing list