[Tutor] question

Deirdre Saoirse deirdre@deirdre.net
Wed, 15 Mar 2000 12:35:20 -0800 (PST)


On Wed, 15 Mar 2000 amoreira@mercury.ubi.pt wrote:

> Hello!
> 
> Try os.path.isdir, as in
> 
> for fname in os.listdir(os.curdir)
>     if os.path.isdir(fname):
>         print fname+'/'
>     else:
>         print fname

Please note that this is not portable across operating systems.
Specifically, it'll break on Windows and MacOS. A more portable version:

     if os.path.isdir(fname):
         print fname + os.sep
     else:
         print fname

-- 
_Deirdre   *   http://www.linuxcabal.org   *   http://www.deirdre.net
       "In /dev/null, no one can hear you scream"