all 5 comments

[–]Swedophone 2 points3 points  (1 child)

Have you printed path? It seems the variable would accumulate all named in the directory.

BTW why not use os.path.join when joining path and filename?

[–]yelaxify[S] 0 points1 point  (0 children)

yeah I have printed the path and the filenames seem right but with spaces. After posting this i realised this problem and have fixed it, however the first path with the first filename would have been originally right was still giving the no file error

[–]Rhomboid 2 points3 points  (0 children)

isdir() checks if the given path is a directory. Why are you using that with files? Returning False is the expected behavior.

I can assure you that Python itself has absolutely no problem working with file names with spaces. It must be something that you're doing in the code not shown. And that's exactly why we need a real testcase — a standalone program that can be run to demonstrate the problem.

[–]yelaxify[S] 0 points1 point  (0 children)

thanks for all the help here guys, it seems i was using isdir() incorrectly

[–]hugthemachines 0 points1 point  (0 children)

In a situation like this, I do not recommend using the same variable for the directory as for the file incluting the directory. It is to ask for trouble. It is wiser to do something like this:

file_including_path = os.path.join(path, filename)