Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95324

Re: Ensure unwanted names removed in class definition

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Ensure unwanted names removed in class definition
Date 2015-08-13 08:55 +1000
References <85fv3oj2y6.fsf@benfinney.id.au> <55CB62BE.4080403@mrabarnett.plus.com>
Newsgroups comp.lang.python
Message-ID <mailman.147.1439420405.3627.python-list@python.org> (permalink)

Show all headers | View raw


MRAB <python@mrabarnett.plus.com> writes:

> Have you thought about catching the NameError?

I had not, but that is obvious now you say it. Thanks.

Where there isn't a more elegant solution, I'll use that. It might not
be elegant, but it's at least clear and expressive of the intent.


Jussi Piitulainen <ei@kun.ei.invalid> writes:

> Make them an implementation detail:
>
>     plumage = [
>         (__foo__, __bar__) for (__foo__, __bar__) in feathers.items()
>         if __bar__ == "beautiful" ]

That still makes the name persist, so doesn't meet the requirements. It
also commits the further mistake of using a ‘__dunder__’ name style for
something that *isn't* a Python magic attribute.

Thanks for the attempt :-)

-- 
 \                 “Teeth extracted by the latest Methodists.” dentist |
  `\                                          advertisement, Hong Kong |
_o__)                                                                  |
Ben Finney

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Ensure unwanted names removed in class definition Ben Finney <ben+python@benfinney.id.au> - 2015-08-13 08:55 +1000

csiph-web