Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21711
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'attribute': 0.07; 'exception,': 0.07; 'python': 0.08; 'received:mail- lpp01m010-f46.google.com': 0.09; 'def': 0.13; "'a'": 0.16; 'handy': 0.16; 'self,': 0.16; 'subject:instance': 0.16; 'suggestions?': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'instance': 0.18; 'cheers,': 0.20; 'to:2**1': 0.21; 'header:In- Reply-To:1': 0.22; 'string': 0.24; 'do,': 0.25; 'creating': 0.25; 'guess': 0.26; 'cc:2**0': 0.26; 'looks': 0.27; 'not.': 0.28; 'message-id:@mail.gmail.com': 0.29; 'see,': 0.29; 'class': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'kelly': 0.30; 'str': 0.30; 'error': 0.30; 'on,': 0.31; 'version': 0.32; 'received:209.85.215.46': 0.32; 'thu,': 0.32; 'thanks': 0.32; 'it.': 0.33; 'instead': 0.33; 'object': 0.33; 'test': 0.34; 'subject:getting': 0.34; '...': 0.35; 'something': 0.35; 'passed': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'think': 0.38; 'getting': 0.38; 'received:209.85.215': 0.39; 'received:209': 0.39; 'here': 0.64; 'said:': 0.67; 'blank': 0.74; '2.7.': 0.84; 'difference.': 0.84; 'ian,': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=mAfXH+yx1BsBaKyl7HVJitWvzLDjloeXa80+BHBpItA=; b=Hj9XaBHRmh5fJ03/Sh087/6J3mKoa/t5bq0glHvFbGA4hvVWeD5VduaqkgI0Rx7iTD TvXrQa9HOka3lKt+xC1Udd7cSUgoryrFpwgNn6SlDjTYO10nnZpTtuJYwjS+c7nW66uT UkeHtu2lBA+RjKMK/D5sgLnF/dOQJ/Lyj6dKK9U1gDmckvEWgvJvg7qlNpMBDso9WKhT 8TTa/764nwtk4jEb0uut5QB6neUbdlPq8QezV2X5CbiJWrczcyEBY08qHs5W712j6K4L BzbsjQoKH2QRmGehPwkQlvb5KaKbIeo+yDZL7stM2if1olzzqnmLKQRmHd/YblFrjiep JMVg== |
| MIME-Version | 1.0 |
| In-Reply-To | <5B80DD153D7D744689F57F4FB69AF474026B9706@SCACMX008.exchad.jpmchase.net> |
| References | <5B80DD153D7D744689F57F4FB69AF474026B9264@SCACMX008.exchad.jpmchase.net> <jjte9l$4iq$1@dough.gmane.org> <5B80DD153D7D744689F57F4FB69AF474026B9625@SCACMX008.exchad.jpmchase.net> <CALwzid=O78BW2yqh6_4pSAVVXuSxqM5GVzXdhyPnLY7KUWvbaQ@mail.gmail.com> <5B80DD153D7D744689F57F4FB69AF474026B9706@SCACMX008.exchad.jpmchase.net> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 15 Mar 2012 14:33:46 -0600 |
| Subject | Re: Context Manager getting str instead of AttributeError instance |
| To | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | "python-list@python.org" <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.701.1331843658.3037.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1331843658 news.xs4all.nl 6864 [2001:888:2000:d::a6]:55863 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:21711 |
Show key headers only | View raw
On Thu, Mar 15, 2012 at 2:25 PM, Prasad, Ramit
<ramit.prasad@jpmorgan.com> wrote:
>> > ...
>> > (<type 'exceptions.AttributeError'>, "'A' object has no attribute 'x'",
>> <traceback object at 0x1817F648>)
>> > AttributeError: 'A' object has no attribute 'x'
>> >
>> > As you can see, I am getting a string while you are not.
>>
>>Ian Kelly said:
>> Looks like a version difference. I don't have Python 2.6 handy to
>> test on, but I get a str in Python 2.5 and an AttributeError instance
>> in Python 2.7.
>
> Thanks Ian, that was the key! I guess I will just have to work around it.
> Any suggestions? I am thinking about just creating a blank instance of
> the error class since that the class gets passed successfully.
Well, for what you want to do, I don't think you need an instance at
all -- just use issubclass instead of isinstance:
def __exit__( self, exceptionClass, exception, tracebackObject ):
if issubclass( exceptionClass, self.exceptionClasses ):
#do something here
Cheers,
Ian
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Context Manager getting str instead of AttributeError instance Ian Kelly <ian.g.kelly@gmail.com> - 2012-03-15 14:33 -0600
csiph-web