Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #84595
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <marco.buttu@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; '(of': 0.07; 'attribute': 0.07; 'error:': 0.07; 'classes.': 0.09; 'instance.': 0.09; 'obj': 0.09; 'objects,': 0.09; 'python:': 0.09; 'sub': 0.09; 'type,': 0.09; 'python': 0.11; '>the': 0.16; 'attribute.': 0.16; 'descriptor': 0.16; 'invocation': 0.16; 'marco': 0.16; 'object)': 0.16; 'type)': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'bit': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'statement': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'phone:': 0.31; 'class': 0.32; 'says': 0.33; '"the': 0.34; 'problem': 0.35; 'objects': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'object,': 0.36; 'too': 0.37; 'to:addr:python- list': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'therefore,': 0.64; 'charset:windows-1252': 0.65; 'details': 0.65; 'between': 0.67; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'this...': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:message-id:date:reply-to:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=wJDsYVmlAxve7epBqyeVf1kTywOrCNBCOTE539F9F1Q=; b=So5q66WNcgM8uYFysylQVA8Jav4bjEIB+iSfsu6Aa7qS0euQ+mdWL3ylkG+hMHzNCi L4r/RkyfKJT2mN6Q4fqiSqGwC7h2LS6VrhqF7YhT6b7KB6qRo3crXXEvqRhpyYnSEES6 Xf13+jZo0FIc1GAij2+T4QuSE9Mn5ZHCwwDpKnpCb5dxyTjr6EelBoOU6sHcGAm4ETBZ 9gK5UkimFhfHREDaws7Ftdm6paVjcbZloBUg+YWcZpMh5g7FJyZQNea2PTtXcUQbYrgB SNI5GUcZL1fDiBBrG6iOvL+fDbhX3G7F/ZUbY91DRGxQwRCcU1OUE+zRfHn/4G1myS7d LtCw== |
| X-Received | by 10.180.72.199 with SMTP id f7mr14095829wiv.58.1422108759951; Sat, 24 Jan 2015 06:12:39 -0800 (PST) |
| From | Marco Buttu <marco.buttu@gmail.com> |
| X-Google-Original-From | Marco Buttu <mbuttu@oa-cagliari.inaf.it> |
| Date | Sat, 24 Jan 2015 15:12:36 +0100 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: __bases__ misleading error message |
| References | <1a194e0a0b738d205de54180fa7@nntp.aioe.org> <54c39366$0$13006$c3e8da3$5496439d@news.astraweb.com> |
| In-Reply-To | <54c39366$0$13006$c3e8da3$5496439d@news.astraweb.com> |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Mailman-Approved-At | Mon, 26 Jan 2015 09:15:18 +0100 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | mbuttu@oa-cagliari.inaf.it |
| 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.18142.1422260120.18130.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1422260120 news.xs4all.nl 2847 [2001:888:2000:d::a6]:53601 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:84595 |
Show key headers only | View raw
On 24/01/2015 13:43, Steven D'Aprano wrote: > Mario Figueiredo wrote: >> > class Sub: >> > pass >> > >> > foo = Sub() >> > >> > Sub.__bases__ >> > foo.__bases__ >> > >> >The last statement originates the following error: >> > >> > AttributeError: 'Sub' object has no attribute '__bases__' > It's a bit ambiguous, but the way to read it is to think of object as a > synonym for instance. In my opinion it is not ambiguous, because as you say in Python an object is a synonym for instance. We can say in Python an object is an instance of the type object, that's all. And that's why everything is an object in Python: >>> isisntace(foo, object) # For every foo True So a class (a type) is an instance too (of its metaclass). Therefore, the message says that the Sub instance has no attribute '__bases__'. In fact the Sub object (instance) has no attribute '__bases__' because it is not an instance of type, and only types (classes) have this attribute. That means in Python sometimes, like the OP one, we have to underline the difference between types (classes) and non-types (non-classes) objects, instead of between objects and classes. The problem is in the Python documentation there is also a bit of confusion about this... In the descriptor howto: "The details of invocation depend on whether obj is an object or a class" :/ -- Marco Buttu INAF-Osservatorio Astronomico di Cagliari Via della Scienza n. 5, 09047 Selargius (CA) Phone: 070 711 80 217 Email: mbuttu@oa-cagliari.inaf.it
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
__bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-24 10:16 +0000
Re: __bases__ misleading error message Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-24 23:43 +1100
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-24 22:14 +0100
Re: __bases__ misleading error message Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-24 14:45 -0700
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-24 23:09 +0100
Re: __bases__ misleading error message Chris Angelico <rosuav@gmail.com> - 2015-01-25 09:25 +1100
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-24 23:33 +0100
Re: __bases__ misleading error message Chris Angelico <rosuav@gmail.com> - 2015-01-25 09:37 +1100
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-24 23:59 +0100
Re: __bases__ misleading error message Terry Reedy <tjreedy@udel.edu> - 2015-01-24 16:58 -0500
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-24 23:02 +0100
Re: __bases__ misleading error message Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-24 15:16 -0700
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-24 23:36 +0100
Re: __bases__ misleading error message Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-25 14:18 +1100
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-25 12:07 +0100
Re: __bases__ misleading error message Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-25 23:00 +1100
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-25 13:49 +0100
Re: __bases__ misleading error message Marko Rauhamaa <marko@pacujo.net> - 2015-01-25 14:53 +0200
Re: __bases__ misleading error message Terry Reedy <tjreedy@udel.edu> - 2015-01-25 16:35 -0500
Re: __bases__ misleading error message Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-25 19:21 -0700
Re: __bases__ misleading error message Marco Buttu <marco.buttu@gmail.com> - 2015-01-24 23:09 +0100
Re: __bases__ misleading error message Marco Buttu <marco.buttu@gmail.com> - 2015-01-24 15:12 +0100
Re: __bases__ misleading error message Terry Reedy <tjreedy@udel.edu> - 2015-01-24 14:24 -0500
Re: __bases__ misleading error message Mario Figueiredo <marfig@gmail.com> - 2015-01-24 22:03 +0100
Re: __bases__ misleading error message Marco Buttu <marco.buttu@gmail.com> - 2015-01-24 22:51 +0100
Re: __bases__ misleading error message Terry Reedy <tjreedy@udel.edu> - 2015-01-24 19:55 -0500
Re: __bases__ misleading error message Marco Buttu <marco.buttu@gmail.com> - 2015-01-25 11:30 +0100
Re: __bases__ misleading error message Marco Buttu <marco.buttu@gmail.com> - 2015-01-24 22:51 +0100
csiph-web