On 01/29/2013 08:21 AM, iMath wrote:
why [os.path.join(r'E:\Python', name) for name in []] returns [] ?
please explain it in detail !


[ os.path.join(r'E:\Python', name) for name in [] ]

It'd be nice if you would explain what part of it bothers you. Do you know what a list comprehension is? Do you know how to decompose a list comprehension into a for-loop? Do you know that [] is an empty list object?


res = []
for name in []:
    res.append( XXXX )

Since the for loop doesn't loop even once, the result is the initial value, the empty loop.

--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to