On 12/16/18 8:21 PM, Jani Nikula wrote:
On Sat, 15 Dec 2018, Bruno Santos <brunomanuelsantos@xxxxxxxxxxxxxxxxxx>
On 12/13/18 10:11 PM, Jani Nikula wrote:
+ return [os.path.join(path, f) for f in sorted(os.listdir(path))
+ if f.endswith(testext)]
You can use a generator here. I'm sure performance doesn't matter, but it's
If you do so, it will break one of the cases you use it on, and you'd need
list(get_testcases()), which is a bit ugly and defeats the purpose, or use
And while at it, this could be a bit more readable with yield, although
may vary in that regard:
for f in sorted(os.listdir(path)):
yield os.path.join(path, f)
Up to you though.
I guess my only question is, won't the sorted() there build a list no
matter what? What does the generator gain us?
I think I lean towards the explict yield.