Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17231
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.straub-nv.de!feed.xsnews.nl!border-3.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ericsnowcurrently@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.044 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'python': 0.08; 'received:209.85.160.174': 0.09; 'received:mail- gy0-f174.google.com': 0.09; 'am,': 0.12; 'attribute:': 0.16; 'magic.': 0.16; 'metaclasses': 0.16; 'superfluous': 0.16; 'cc:addr :python-list': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'ryan': 0.18; 'cc:no real name:2**0': 0.20; "aren't": 0.21; 'dec': 0.22; 'header :In-Reply-To:1': 0.22; 'opens': 0.23; 'steve': 0.24; 'cc:2**0': 0.24; 'originally': 0.24; 'subject:" ': 0.28; 'cloud': 0.28; 'needed,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'explicit': 0.29; "skip:' 10": 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'class': 0.29; 'definition': 0.30; 'rarely': 0.30; 'tue,': 0.32; 'sort': 0.33; 'received:209.85.160': 0.33; 'eric': 0.34; 'approach.': 0.34; 'lie': 0.34; 'however,': 0.36; 'question': 0.36; 'subject:with': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'relatively': 0.39; 'being': 0.39; 'tool': 0.39; 'subject: (': 0.40; 'received:209': 0.40; 'might': 0.40; 'more': 0.61; '2011': 0.61; 'worth': 0.61; 'your': 0.61; 'world': 0.62; 'details': 0.65; 'works,': 0.68; '(make': 0.84; '03:56': 0.84; '12:14': 0.84; 'hand.': 0.84; 'snow': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=p8xmorOgS3j/U7rSEDh9xwDvGUIEE+SElMuOREOhDp4=; b=CRIHeaGkrBMBjUAiMK7ycCXtjEUx/3E95khBgMj98N7CMPugiHJ34614my+B7bUCtn NAbGusiwIJJ5QpkxiJ+iRsnzngGxUYLCGGp80NwsqWaGB/58rUiZC46ngRxBc1WxAU9t wMP+AlKS+DKBUsP2Lmok0Bv0cLke/F94EDTx0= |
| MIME-Version | 1.0 |
| In-Reply-To | <jcasif$t18$1@dough.gmane.org> |
| References | <b8092181-c306-40bc-a07a-bb35bc925cf1@18g2000prn.googlegroups.com> <CALFfu7BwozUsp=WB1+66wH9RR1=DQCAprNve7N+LFR2ptGMFWg@mail.gmail.com> <CALFfu7CFLoO75Vq4RaCKK1msTCveSGfDueSBAj-B1mhWZ+XWBw@mail.gmail.com> <jcasif$t18$1@dough.gmane.org> |
| Date | Wed, 14 Dec 2011 12:46:58 -0700 |
| Subject | Re: AttributeError in "with" statement (3.2.2) |
| From | Eric Snow <ericsnowcurrently@gmail.com> |
| To | Lie Ryan <lie.1296@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3653.1323892021.27778.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1323892021 news.xs4all.nl 6868 [2001:888:2000:d::a6]:54749 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:17231 |
Show key headers only | View raw
On Wed, Dec 14, 2011 at 12:14 PM, Lie Ryan <lie.1296@gmail.com> wrote: > On 12/15/2011 03:56 AM, Eric Snow wrote: >> >> On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow<ericsnowcurrently@gmail.com> >> wrote: >> >> If you want to be more dynamic about it you can do it, but it involves >> black magic. Chances are really good that being explicit through your >> class definition is the right approach. > > > Note that the black spice is to use the __class__ attribute: > > foo.__class__.__exit__ = foo.goodbye Good point. 'type(foo).__exit__ ...' might be even better. Regardless, to get the dynamicism to which Steve originally referred (make it work when added directly to the instance), you have to use a metaclass, which is black magic[1]. However, rarely is that sort of thing needed, so the relatively superfluous details would likely only cloud the question at hand. -eric [1] I will point out that metaclasses aren't really all that bad. They are a tool worth understanding, even if you don't use them all the time. Understanding them also opens up a whole new world of understanding how Python works, particularly regarding name lookup.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
AttributeError in "with" statement (3.2.2) Steve Howell <showell30@yahoo.com> - 2011-12-13 21:42 -0800
Re: AttributeError in "with" statement (3.2.2) Eric Snow <ericsnowcurrently@gmail.com> - 2011-12-13 23:05 -0700
Re: AttributeError in "with" statement (3.2.2) Terry Reedy <tjreedy@udel.edu> - 2011-12-14 01:29 -0500
Re: AttributeError in "with" statement (3.2.2) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-14 08:01 +0000
Re: AttributeError in "with" statement (3.2.2) 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-14 08:08 -0800
Re: AttributeError in "with" statement (3.2.2) 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-14 08:28 -0800
Re: AttributeError in "with" statement (3.2.2) Steve Howell <showell30@yahoo.com> - 2011-12-14 09:16 -0800
Re: AttributeError in "with" statement (3.2.2) Terry Reedy <tjreedy@udel.edu> - 2011-12-14 18:13 -0500
Re: AttributeError in "with" statement (3.2.2) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-15 05:01 +0000
Re: AttributeError in "with" statement (3.2.2) MRAB <python@mrabarnett.plus.com> - 2011-12-15 05:15 +0000
Re: AttributeError in "with" statement (3.2.2) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-15 07:21 +0000
Re: AttributeError in "with" statement (3.2.2) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-12-16 09:34 +1300
Re: AttributeError in "with" statement (3.2.2) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-15 07:47 +0000
Re: AttributeError in "with" statement (3.2.2) Steve Howell <showell30@yahoo.com> - 2011-12-15 05:35 -0800
Re: AttributeError in "with" statement (3.2.2) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-16 03:34 +0000
Re: AttributeError in "with" statement (3.2.2) Terry Reedy <tjreedy@udel.edu> - 2011-12-15 19:39 -0500
Re: AttributeError in "with" statement (3.2.2) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-16 09:22 +0000
Re: AttributeError in "with" statement (3.2.2) Terry Reedy <tjreedy@udel.edu> - 2011-12-16 17:05 -0500
Re: AttributeError in "with" statement (3.2.2) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-17 01:26 +0000
Re: AttributeError in "with" statement (3.2.2) Terry Reedy <tjreedy@udel.edu> - 2011-12-17 21:09 -0500
Re: AttributeError in "with" statement (3.2.2) Ethan Furman <ethan@stoneleaf.us> - 2011-12-16 15:26 -0800
Re: AttributeError in "with" statement (3.2.2) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-17 03:05 +0000
Re: AttributeError in "with" statement (3.2.2) Ethan Furman <ethan@stoneleaf.us> - 2011-12-16 16:34 -0800
Re: AttributeError in "with" statement (3.2.2) Peter Otten <__peter__@web.de> - 2011-12-14 11:02 +0100
Re: AttributeError in "with" statement (3.2.2) Eric Snow <ericsnowcurrently@gmail.com> - 2011-12-14 09:56 -0700
Re: AttributeError in "with" statement (3.2.2) Lie Ryan <lie.1296@gmail.com> - 2011-12-15 06:14 +1100
Re: AttributeError in "with" statement (3.2.2) Eric Snow <ericsnowcurrently@gmail.com> - 2011-12-14 12:46 -0700
csiph-web