directory listing
Peter Hansen
peter at engcorp.com
Fri Nov 11 21:03:02 EST 2005
Shi Mu wrote:
> On 11/11/05, Fredrik Lundh <fredrik at pythonware.com> wrote:
>>Shi Mu wrote:
>>>def buildList( directory='c:\TEMP' ):
>>> dirs = [ ]
>>> listing = os.listdir(directory)
>>> for x in listing:
>>> x = os.path.join(directory, x)
>>> print x
>>> if os.path.isdir(x):
>>> dirs.append(x)
>>> return dirs
>
> It works but i am curious why the line of "print x" does not show
> anything. many thanks!
Did you use directory='c:\TEMP' as shown above, or directory='c:\temp' ?
If you used the lower case version, you are not really checking the
temp directory, since \t represents a TAB character. If that's the
case, try using a forward slash instead: c:/temp .
-Peter
More information about the Python-list
mailing list