I'm a python newbie. I come from a C/C++ background and it's really difficult for me to get my head around some of python's concepts. I have stumbled upon this block of code which just plain confuses me:
file_names = [os.path.join(label_directory, f)
for f in os.listdir(label_directory)
if f.endswith(".ppm")]
So, it's an array that joins label_directory with a variable f (both strings), which is initially uninitialized. The for loop then populates the variable f if the condition f.endswith(".ppm") is true.
Now, from my C/C++ perspective I see this:
A for loop that has an if statement that returns True or False. Where is the logic that excludes all the files that don't end with ".ppm" extension?