Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61538
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.018 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'attribute': 0.07; 'exception.': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'block.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'func': 0.16; 'subject:between': 0.16; 'throw': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; '8:30': 0.31; 'except': 0.35; 'test': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'pm,': 0.38; 'sure': 0.39; 'easy': 0.60; 'expression': 0.60; 'caused': 0.69; 'subject:skip:o 10': 0.84; 'to:none': 0.92; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=8UKhJ9qgx1GC2dkzQHzPG0arypF9Y71ib46WRvxJhb8=; b=dlXGgaa/56FUZwfwoOSoVSn5TyXqfg6EE425ogbY933e/smgkKkABWnuVvbRi7zrjq N27+AI9KNlxP003b3SCRBB2rGsx6DMGoakecaH6nLWXMf3N4fm5m0+yKXrqw6QgQznqn dkiblyaWpfzZSEuRxhUJcbQuOnevFIvMUZkJfjFAW8praLgkrNS9ngGua9B+ZkEF33q6 medMLl2ovUILGukrQYEehwxnJWhAl0B/e8sT+7Nud6DwTTEcp/f+7tjXse3MADLJ7IeT JkjhglkYxNfYBoH4S7i6PeEErkZm/RqR9pjA2gZmudTttjX6WV2/pry6K6wyboz6izbK 3MiA== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.248.33 with SMTP id yj1mr472004pbc.45.1386754723453; Wed, 11 Dec 2013 01:38:43 -0800 (PST) |
| In-Reply-To | <l89bc2$cb1$1@ger.gmane.org> |
| References | <52A82101.7030307@galileo-press.de> <l89bc2$cb1$1@ger.gmane.org> |
| Date | Wed, 11 Dec 2013 20:38:43 +1100 |
| Subject | Re: Differences between obj.attribute and getattr(obj, "attribute") |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3876.1386754732.18130.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386754732 news.xs4all.nl 2891 [2001:888:2000:d::a6]:46780 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:61538 |
Show key headers only | View raw
On Wed, Dec 11, 2013 at 8:30 PM, Jurko Gospodnetić
<jurko.gospodnetic@pke.hr> wrote:
> Also, you can not test whether an object has an attribute when using the
> object.attribute access method without raising/catching an exception and
> then it can be hard to make sure no other code caused the exception.
It's pretty easy to make sure no other code caused the exception -
just have no other code inside the try block.
x.foo(input().split(" ")[4]) # Might throw from any point in the expression
try:
func = x.foo
except AttributeError:
deal_with_error
func(......)
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Differences between obj.attribute and getattr(obj, "attribute") Chris Angelico <rosuav@gmail.com> - 2013-12-11 20:38 +1100
csiph-web