I'm getting a list of files in a project, which can all range from
src/app.ts
src/component/app/app.ts
m = re.compile(r'(ts|js)config.json$')
for file in files:
if m.search(file):
return True
else:
self.writeFile()
You could just unindent your else
block so it applies to for
:
for file in files:
if m.search(file):
return True
else:
self.writeFile()
note that in that case it's not as interesting as with the break
case, you could simply write:
for file in files:
if m.search(file):
return True
self.writeFile()
since if pattern matches it returns so writeFile
is not reached.