[os.path.join(r'E:\Python', name) for name in []] returns []
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Jan 29 08:33:26 EST 2013
iMath wrote:
> why [os.path.join(r'E:\Python', name) for name in []] returns [] ?
Because you are iterating over an empty list, [].
That list comprehension is the equivalent of:
result = []
for name in []:
result.append( os.path.join(r'E:\Python', name) )
Since you iterate over an empty list, the body of the loop never executes,
and the result list remains empty.
What did you expect it to do?
--
Steven
More information about the Python-list
mailing list