On Wed, Jan 30, 2013 at 12:21 AM, iMath <redstone-c...@163.com> wrote:
> why [os.path.join(r'E:\Python', name) for name in []] returns [] ?
> please explain it in detail !

That's a list comprehension. If you're familiar with functional
programming, it's like a map operation. Since the input list (near the
end of the comprehension, just inside its square brackets) is empty,
so is the result list, and os.path.join is never called.

I've given you a massive oversimplification. The docs are here:

http://docs.python.org/3.3/tutorial/datastructures.html#list-comprehensions

Pro tip: The docs are there before you ask the question, too. You
might find it faster to search them than to ask and wait for an answer
:)

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

Reply via email to