confusion regarding os.path.walk()
Ron Johnson
ron.l.johnson at cox.net
Mon Feb 18 19:06:25 EST 2002
Hello,
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.
Am I doing something wrong?
Here is an examle:
me at rebel:~/test$ python
Python 2.2 (#1, Jan 8 2002, 01:13:32)
[GCC 2.95.4 20011006 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
me at rebel:~/test$ cat test.py
import os.path, string
def test(arg, dirname, names):
print arg
print dirname
names.sort()
for n in names:
print n,
if os.path.isdir(n):
print ' is a DIR'
elif os.path.isfile(n):
print ' is a FILE'
else:
print ' is UNKNOWN'
print '================================'
os.path.walk('.', test, None)
me at rebel:~/test$ python test.py
None
.
bar is a DIR
foo is a DIR
snafu is a DIR
test.py is a FILE
================================
None
./bar
================================
None
./foo
snaggle is UNKNOWN
swizzle is UNKNOWN
================================
None
./foo/swizzle
================================
None
./snafu
================================
TIA,
Ron
--
+------------------------------------------------------------+
| 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