• 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.

    Tags: ,

    Leave a Reply

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

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>