Nonbinary file in Python

Question:

I’m trying to look at all the items we have in a directory, and check whether there are file or directory. Sadly, all of them aren’t directory, neither a file.

import io, sys, os, json
path_input = "C:\Users\Me\AppData\Local\somewhere\"
for file in os.listdir(path_input):
    
    print("Looking at " + file)
    isFile = os.path.isfile(file) # False
    isDir = os.path.isdir(file) # False
    

I’m pretty sure I’m missing something with how I handle file.

Asked By: Portevent

||

Answers:

I forgot to add the path in my function to properly locate the file (or the directory)

    isDirectory = os.path.isdir(path_input+file)

Someone posted the solution but the post got deleted

Answered By: Portevent
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.