HowTo distinguish between File and Directory

S

Scott F

On Win32, is there a function in the standard modules that can take a
pathname and return whether it refers to a File or a Directory?

Scott
 
P

Peter Hansen

Scott said:
On Win32, is there a function in the standard modules that can take a
pathname and return whether it refers to a File or a Directory?

import os
os.path.isfile(name)
os.path.isdir(name)

Is that adequate?

-Peter
 
E

Erik Max Francis

Scott said:
On Win32, is there a function in the standard modules that can take a
pathname and return whether it refers to a File or a Directory?

There's certainly one in the os module: os.path.isdir and
os.path.isfile.
 
S

Scott F

import os
os.path.isfile(name)
os.path.isdir(name)

Is that adequate?

Yes. I only did a dir(os) and thus didn't see the items under path.

Thanks Peter (and Erik).

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top