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


Groups > comp.lang.python > #111125

Re: Making Classes Subclassable

Path csiph.com!feeder.erje.net!1.eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Making Classes Subclassable
Date Tue, 5 Jul 2016 08:41:44 -0600
Lines 30
Message-ID <mailman.99.1467729753.2295.python-list@python.org> (permalink)
References <ca1ee22e-9769-4e76-81f3-b9d0dcb55212@googlegroups.com> <87eg79q1i0.fsf@handshake.de> <mailman.59.1467619073.2295.python-list@python.org> <337f8071-ef4a-4ac5-867b-a5320c684730@googlegroups.com> <577b707f$0$2917$c3e8da3$76491128@news.astraweb.com> <CALwzid=2BVpWYWEAvWECDQ8WxDfM+9q9F=KLH1mDp=zccJR+iw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de Z4SmpktGUpn5pQxQbHgS/wPUgBMHGid/4g0L1I9L6jnA==
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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'that?': 0.05; '__name__': 0.07; 'attributes': 0.07; 'cc:addr:python-list': 0.09; 'name):': 0.09; 'def': 0.13; '(there': 0.16; '2016': 0.16; 'cc:name:python': 0.16; 'received:io': 0.16; 'received:mail-oi0-x230.google.com': 0.16; 'received:psf.io': 0.16; 'subject:Classes': 0.16; 'x()': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'lawrence': 0.22; 'am,': 0.23; 'header :In-Reply-To:1': 0.24; 'skip:_ 20': 0.26; 'message- id:@mail.gmail.com': 0.27; 'certain': 0.31; 'skip:s 30': 0.31; 'class': 0.33; "d'aprano": 0.33; 'int': 0.33; 'steven': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'monday,': 0.36; 'subject:: ': 0.37; 'test': 0.39; 'jul': 0.72; 'subject:Making': 0.84; 'to:none': 0.91
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:cc :content-transfer-encoding; bh=+e++z5Ewqb3PNMekGr+sfs8bWT7GwPsl8JGwudWsYJ0=; b=ay/2+XI7Efy23YGWgb8KqeklKM7WZO9VVXHsKo3O2Y+N20SXnrS/ZqE60YzuKI7Hja fbVj/Omd7hddIPabmdtZwuQsWcYhq3baOemb98X46alGDSeiGzwsZIT9ijnjfM7moVcl RPB1QW95LdPfOOpGXCJYx5NgxX/QlsBIHKcy8ksrU5YycX0tcawgxjwqYh13VtnyiGrE +309ZjAGGDVAzIrwm7lEm220HhpNvvt29liIBHHywfW9ZFGGaGQN83u0HsvDCKclvTBQ P2U0tRBBDV8mucQsfx60a+GMa14uCktUXV+I8k99WEsQnwRNIhUMC/pNlIvydYXGzx22 2pFQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc:content-transfer-encoding; bh=+e++z5Ewqb3PNMekGr+sfs8bWT7GwPsl8JGwudWsYJ0=; b=IdpWgTg3TrKOxRHPtJOKLbN1sunbHhP2t7VBPkBjcCUbBgHTcHO+/U5SlJweIo40Zy khrpnXoj1Yyws/D3F4CYRUwydpevlbcvlWKs7Ez0jQk0xuekN3uRE6zYOU6z1i//PhlC TiGKN46Xrb0bC6fmQ88mVWO0YtRiBZUaEJv+x/g1CHnERXIxfCxpSgw/Mh/gaF8545SY y577f3ODcz8F2MD3tJ6/8ExCDQ9DhWpGBs63TSWlujb+YS0+F/6Dw4vXoEaKbXWCU8s0 tlNORyt4SQEKeW3hAEnO8ir7qUAQXimXyxnAm/n2EZeGcKhGWj3+rRnLf8T0xlfq1rjC fayQ==
X-Gm-Message-State ALyK8tLrOy0u58x8ve/jh637P29XNNixWq2RInYvrFragKSFyotr86/KwSWQk6EmR5dASDEP97FiWRjo0Zo/hg==
X-Received by 10.157.17.147 with SMTP id v19mr9589782otf.11.1467729744090; Tue, 05 Jul 2016 07:42:24 -0700 (PDT)
In-Reply-To <577b707f$0$2917$c3e8da3$76491128@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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>
X-Mailman-Original-Message-ID <CALwzid=2BVpWYWEAvWECDQ8WxDfM+9q9F=KLH1mDp=zccJR+iw@mail.gmail.com>
X-Mailman-Original-References <ca1ee22e-9769-4e76-81f3-b9d0dcb55212@googlegroups.com> <87eg79q1i0.fsf@handshake.de> <mailman.59.1467619073.2295.python-list@python.org> <337f8071-ef4a-4ac5-867b-a5320c684730@googlegroups.com> <577b707f$0$2917$c3e8da3$76491128@news.astraweb.com>
Xref csiph.com comp.lang.python:111125

Show key headers only | View raw


On Tue, Jul 5, 2016 at 2:31 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Monday 04 July 2016 18:34, Lawrence D’Oliveiro wrote:
>
>> On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote:
>>> --> "type(obj)" or "obj.__class__" (there are small differences)
>>> give you the type/class of "obj".
>>
>> When would it not be the same?
>
>
> class X(object):
>     def __getattribute__(self, name):
>         if __name__ == '__class__':
>             return int
>         return super().__getattribute__(name)

Did you actually test that?

py> class X(object):
...     def __getattribute__(self, name):
...         if __name__ == '__class__':
...             return int
...         return super().__getattribute__(name)
...
py> x = X()
py> x.__class__
<class '__main__.X'>

Certain attributes like __class__ and __dict__ are special.

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


Thread

Making Classes Subclassable Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-02 21:31 -0700
  Re: Making Classes Subclassable dieter <dieter@handshake.de> - 2016-07-04 09:57 +0200
    Re: Making Classes Subclassable Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-04 01:34 -0700
      Re: Making Classes Subclassable Michael Selik <michael.selik@gmail.com> - 2016-07-05 05:26 +0000
        Re: Making Classes Subclassable Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-05 00:08 -0700
      Re: Making Classes Subclassable dieter <dieter@handshake.de> - 2016-07-05 09:55 +0200
      Re: Making Classes Subclassable Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-07-05 18:31 +1000
        Re: Making Classes Subclassable Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-05 08:41 -0600
          Re: Making Classes Subclassable Steven D'Aprano <steve@pearwood.info> - 2016-07-06 01:33 +1000
      Re: Making Classes Subclassable Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-05 09:02 -0600
        Re: Making Classes Subclassable Steven D'Aprano <steve@pearwood.info> - 2016-07-06 01:41 +1000
        Re: Making Classes Subclassable Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-05 19:31 -0700
    Re: Making Classes Subclassable Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-05 20:04 -0700
  Re: Making Classes Subclassable Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-05 08:52 -0600

csiph-web