confusion regarding os.path.walk()
Ron Johnson
ron.l.johnson at cox.net
Mon Feb 18 23:06:12 EST 2002
On 19 Feb 2002 01:33:52 +0100 Chris Liechti <cliechti at gmx.net> wrote:
> Ron Johnson <ron.l.johnson at cox.net> wrote in
> news:20020218180623.086f6c58.ron.l.johnson at cox.net:
> > In the visit callout function, it looks as though after the top
> > level is processed, os.path.isfile() and os.path.isdir() both return
> > 0 when passed elements from the names parameter.
> ...
> > for n in names:
> > print n,
> > if os.path.isdir(n):
> > ...
>
> in "names" there are only filenames with no path. to access the files
> you must join the path back to the name:
>
> for n in names:
> file = os.path.join(path, n)
> print file,
> if os.path.isdir(file):
> ...
Thinking that that might be the problem, I used os.path.realpath().
However, even that didn't work. Why wouldn't testing an absolute
filename work?
os.path.join() worked. Thanks.
--
+------------------------------------------------------------+
| Ron Johnson, Jr. Home: ron.l.johnson at cox.net |
| Jefferson, LA USA http://ronandheather.dhs.org:81 |
| |
| 484,246 sq mi are needed for 6 billion people to live, 4 !
! persons per lot, in lots that are 60'x150'. |
! That is ~ California, Texas and Missouri. !
! Alternatively, France, Spain and The United Kingdom. |
+------------------------------------------------------------+
More information about the Python-list
mailing list