Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The POSIX solution is
stat():Basically, you hand it an instance of the
struct stat, and if the call succeeds (check this first!) you get various fields filled in that describe the file.You can then use the
S_ISDIR()macro on thest_modefield to figure out if it’s a directory. I suspect this is what Python does, under the hood.