Files and Directories

Gerrit Holl gerrit.holl at pobox.com
Mon Feb 7 09:50:05 EST 2000


Joshua Macy wrote on 949894817:
> Patrick K Moorman wrote:
> > 
> > Thanks to everyone who answered my last question, it is good reminder that
> > computers do *ONLY* what they are told.  I am trying to write a little
> > script that will rename files in multiple directories.  What am a looking
> > for is a way to take each item returned by os.listdir() and test to see if
> > it is a file or a directory.  I have gone through the lib reference but I
> > did not see anything that would work.  I know very little about programing
> > or Pyhton (if you haven't guess yet)  and I am learning by doing.  Or not
> > doing as the case is right now :)
> 
> 
> os.isdir(path) will return true for a directory, and os.isfile(path)
> will return true for a regular file.

os.path.isdir and os.path.isfile
   ~~~~              ~~~~

regards,
Gerrit.

-- 
homepage: http://www.nl.linux.org/~gerrit
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O
!M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK----- moc.edockeeg.www//:ptth




More information about the Python-list mailing list