You can use generator expression here, just in case of large dir. You still use it only for iteration.