On Thu, Aug 13, 2015 at 1:39 AM, Peter Otten <__pete...@web.de> wrote: > But I would probably use a generator expression. These don't leak names: > > Python 2.7.6 (default, Jun 22 2015, 17:58:13) > [GCC 4.8.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> class Parrot: > ... a = [per for per in "abc"] > ... b = list(trans for trans in "def") > ...
Ooh neat trick! Much cleaner than the explicit lambda that I suggested. Withdrawing my recommendation in favour of this (but with an explanatory comment explaining why list(genexp) is used rather than a list comp). ChrisA -- https://mail.python.org/mailman/listinfo/python-list