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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Python 3.6 version of the above answer, using
os– assuming that you have the directory path as astrobject in a variable calleddirectory_in_str:Or recursively, using
pathlib:rglobto replaceglob('**/*.asm')withrglob('*.asm')Path.glob()with'**/'added in front of the given relative pattern:Original answer: