I need to iterate through all .asm files inside a given directory and do some actions on them.
How can this be done in a efficient way?
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
|
Original answer:
Python 3.6 version of the above answer, using
Or recursively, using
|
|||||||||||||||||||||
|
|
You can try using glob module
|
||||
|
|
|
This will iterate over all descendant files, not just the immediate children of the directory:
|
|||||
|
|
Python 3.4 and later offer pathlib in the standard library. You could do:
Or if you don't like list comprehensions:
|
||||
|
|
|
I'm not quite happy with this implementation yet, I wanted to have a custom constructor that does
|
||||
|
|