Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95287 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2015-08-13 01:59 +1000 |
| Last post | 2015-08-13 01:59 +1000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Ensure unwanted names removed in class definition Chris Angelico <rosuav@gmail.com> - 2015-08-13 01:59 +1000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-08-13 01:59 +1000 |
| Subject | Re: Ensure unwanted names removed in class definition |
| Message-ID | <mailman.114.1439395153.3627.python-list@python.org> |
On Thu, Aug 13, 2015 at 1:39 AM, Peter Otten <__peter__@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
Back to top | Article view | comp.lang.python
csiph-web