So I need to parse and read files that have only "fip" or "frp" in them. Rather than just doing all full glob then using an if statment, I decided to search the webs on how I can achieve this. I stumbled on the answers here: Python glob multiple filetypes
Specifically modified my code to use a solution I found:
flist = [f for f_ in [odfslogs_p_handler.glob(e) for e in ('*frp*', '*fip*')] for f in f_]
The p_handler is a pathlib object. Now this code works. I just need some help understanding the wizardry behind it.
I know this is list comprehension but I've only dealth with simple examples. Can someone please explain to me why this works? Also can I chain in more patterns in the inner tuples? So lets say I wanna also parse .txt, and .csv. Is it just a matter of adding a comma and including those patterns inside the tuple ?