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


Groups > comp.lang.python > #111006

Re: Special attributes added to classes on creation

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Special attributes added to classes on creation
Date Sun, 3 Jul 2016 10:58:00 -0600
Lines 26
Message-ID <mailman.43.1467565121.2295.python-list@python.org> (permalink)
References <57793711$0$1611$c3e8da3$5496439d@news.astraweb.com> <CALwzidnMjSBoGakPoewZKtMh7-aT6CWcPB9iQGKoV9gexk=kYA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de /8RqrUyAZsOGahRkidS4ogwVGdzqUdVktjGckyHfAQ7g==
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.039
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'classes,': 0.05; 'newly': 0.09; "'__doc__',": 0.16; '2016': 0.16; 'metaclass': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'when?': 0.16; 'wrote:': 0.16; 'keys': 0.22; 'am,': 0.23; 'defined': 0.23; 'header:In-Reply-To:1': 0.24; 'handling': 0.27; 'message- id:@mail.gmail.com': 0.27; 'sequence': 0.27; "skip:' 10": 0.28; 'skip:q 20': 0.29; "i'm": 0.30; 'classes': 0.30; 'skip:[ 10': 0.31; 'point': 0.33; 'class': 0.33; 'url:python': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'surprised': 0.33; 'that,': 0.34; 'received:google.com': 0.35; 'there': 0.36; 'url:org': 0.36; 'created': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'jul': 0.72; 'to:name:python': 0.84; 'url:datamodel': 0.84; 'subject:Special': 0.91; 'url:reference': 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:to; bh=MHT1Fhv9NkG5IK44Tnk7VbID0/xtWvzPTYuIM+13HfE=; b=f569RLZa3sMOZfnOqMMR1wD3pTQ63+SvOf7W6IMJuEZaEAEvRNnac0dYr1EAVvxIqn 59EqMg08DZF70cufzCyG8PViYFBnwIf14KyRmgWNdD/Sw+O0wmpFmiq+Hsm/eDE9awi3 QsqB5DzrP0Jr4WHpfjLrK3tfRkz08+yedsLydqU/UeEd2xbhlV5e9KxHHywn6OVSVGyD C5VAoZjW4piMDrsh9XCCgdMkANlDQkimZsVkWisgP+BOxlyUTNV2O2crKN6GXdXxKlpB NpfOTyDlkKef3+IolvGKa9WHlLz35isLfbMjIULq2B5qJAhkDsYepOdHYUu5/qtvBztq 3NRQ==
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:to; bh=MHT1Fhv9NkG5IK44Tnk7VbID0/xtWvzPTYuIM+13HfE=; b=R4zsS9/tT5Q/EimTuUeMj84fqbo3I1cStoXayYb9a8m5u7L0+B9wPKDWORFUQXYj3m P4Niu4QtB6o5ERLpUJ8xy45S6pbNWKjrY1DRL6Yo4Ffd2VLWqKIbpIlTUVpFnkOEyGHn dy+rxqyOlB93EBUDXJKC/zw0ObWJs1drHeSPofgA4vTrGiBzZT86pEyCVQHEiKHIsUtb 9KpI0HarvnAxRj4O32gdjMs7VfWxiehTogldZOkcLaLKfImDE/tVBpETPeH0sTf2d3iF eyLrx/A0eazjl3p/oPCmw25ORbXZCfd8SyO1eJjhAW+P5RtDfpaFUPQxIi8YzlHKZ0FA 1Z0Q==
X-Gm-Message-State ALyK8tLTyEZEyqCqRp78QFBdOaV7a8K9MsOlI24fS2ZPQgEgJCjaab02MViHk6cLt352f0p3jBqamBV7gbFt0w==
X-Received by 10.202.225.212 with SMTP id y203mr4225205oig.47.1467565119705; Sun, 03 Jul 2016 09:58:39 -0700 (PDT)
In-Reply-To <57793711$0$1611$c3e8da3$5496439d@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 <CALwzidnMjSBoGakPoewZKtMh7-aT6CWcPB9iQGKoV9gexk=kYA@mail.gmail.com>
X-Mailman-Original-References <57793711$0$1611$c3e8da3$5496439d@news.astraweb.com>
Xref csiph.com comp.lang.python:111006

Show key headers only | View raw


On Sun, Jul 3, 2016 at 10:02 AM, Steven D'Aprano <steve@pearwood.info> wrote:
> If I then try it against two identical (apart from their names) classes, I
> get these results:
>
>
> py> @process
> ... class K:
> ...     x = 1
> ...
> ['__dict__', '__doc__', '__module__', '__weakref__', 'x']
> py> class Q(metaclass=process):
> ...     x = 1
> ...
> ['__module__', '__qualname__', 'x']
> Now if I check the newly created Q, I see the same keys K has:
>
> py> sorted(Q.__dict__.keys())
> ['__dict__', '__doc__', '__module__', '__weakref__', 'x']
>
>
> Is there any documentation for exactly what keys are added to classes when?

I'm only aware of the sequence defined at
https://docs.python.org/3/reference/datamodel.html#customizing-class-creation.
Based on that, I'm surprised to even see __module__ and __qualname__
in there at the point when the metaclass is handling it.

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


Thread

Special attributes added to classes on creation Steven D'Aprano <steve@pearwood.info> - 2016-07-04 02:02 +1000
  Re: Special attributes added to classes on creation Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-03 10:58 -0600
  Re: Special attributes added to classes on creation eryk sun <eryksun@gmail.com> - 2016-07-03 23:07 +0000
  Re: Special attributes added to classes on creation Xiang Zhang <zhangyangyu0614@gmail.com> - 2016-07-04 03:22 -0700

csiph-web