Scope of list comprehension iterator in Python

Know about this?

x = [i * 2 for i in [1, 2, 3, 4]]

Be careful. The scope of "i" is not limited to the expression it is used in.


via blog.vucica.net

Leave a Reply

Your email address will not be published. Required fields are marked *

 

What is 8 + 15 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

This site uses Akismet to reduce spam. Learn how your comment data is processed.