Popular recipes by He Gu http://code.activestate.com/recipes/users/4189822/2014-04-21T20:09:43-07:00ActiveState Code RecipesThe Secret Name of List Comprehensions (Python) 2014-04-21T20:09:43-07:00He Guhttp://code.activestate.com/recipes/users/4189822/http://code.activestate.com/recipes/578865-the-secret-name-of-list-comprehensions/ <p style="color: grey"> Python recipe 578865 by <a href="/recipes/users/4189822/">He Gu</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). </p> <p>Sometimes you want to have a list comprehension refer to itself, but you can't because it isn't bound to a name until after it is fully constructed. However, the interpreter creates a secret name that only exists while the list is being built. That name is (usually) "_[1]", and it refers to the bound method "append" of the list. This is our back door to get at the list object itself.</p>