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


Groups > comp.lang.python > #15075

Re: __dict__ attribute for built-in types

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'attributes': 0.05; 'cpython': 0.05; 'attribute': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; '*is*': 0.09; 'builtin': 0.09; 'determines': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'classes,': 0.13; '6:52': 0.16; 'assignable': 0.16; 'assignment.': 0.16; 'attribute,': 0.16; 'attributes.': 0.16; 'instances.': 0.16; 'reedy': 0.16; '{}"': 0.16; 'wrote:': 0.16; 'advance': 0.18; 'jan': 0.19; 'so.': 0.22; 'assume': 0.22; 'header:In-Reply-To:1': 0.22; 'restrict': 0.23; 'pm,': 0.24; "i'm": 0.27; 'classes': 0.28; 'true,': 0.29; 'also.': 0.30; 'class': 0.30; 'to:addr:python- list': 0.33; '...': 0.34; 'header:User-Agent:1': 0.34; 'but,': 0.34; 'be,': 0.34; 'safely': 0.34; 'sense,': 0.34; 'header:X -Complaints-To:1': 0.35; 'beginning': 0.36; 'none': 0.37; 'are.': 0.37; 'but': 0.37; 'something': 0.37; 'could': 0.38; 'received:org': 0.38; 'some': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'user': 0.39; 'to:addr:python.org': 0.39; 'subject': 0.61; 'believe': 0.65; 'details': 0.65; 'violation': 0.67; 'candide': 0.84; 'subject:types': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: __dict__ attribute for built-in types
Date Thu, 27 Oct 2011 22:44:26 -0400
References <4ea92dae$0$20639$426a74cc@news.free.fr> <Xns9F8B7A9C6BEE5duncanbooth@127.0.0.1> <4ea96437$0$24971$426a74cc@news.free.fr> <4ea9d8e6$0$29968$c3e8da3$5496439d@news.astraweb.com> <4ea9e0ba$0$2261$426a74cc@news.free.fr>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-74-109-121-73.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0
In-Reply-To <4ea9e0ba$0$2261$426a74cc@news.free.fr>
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.2270.1319769884.27778.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1319769884 news.xs4all.nl 6863 [2001:888:2000:d::a6]:47820
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15075

Show key headers only | View raw


On 10/27/2011 6:52 PM, candide wrote:

> No but I'm expecting from Python documentation to mention the laws of
> Python ...

The details of CPython builtin classes are not laws of Python. It *is* a 
'law of Python' that classes can use 'slots = ' to restrict the 
attributes of instances. By implication, builtin classes in any 
implementation do not have to allow attribute assignment. I do not 
believe it would be a violation if some implementation did so.

None of this is to say that we could not say something on the subject at 
the beginning of the 'built-in types' chapter of the lib manual.

> OK but I'm talking about classes, not instances :

Yes you are. The class determines whether its instances have assignable 
new attributes.

 > 42 has no __dict__ > attribute but,
 > may be, 43 _has_ such attribute, who knows in advance ? ;)

True, in a sense, but if the class allowed a user to execute
"42.__dict__ = {}" then you could safely assume that "43.xxx = z" should 
work also.

-- 
Terry Jan Reedy

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


Thread

__dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-27 12:08 +0200
  Re: __dict__ attribute for built-in types Arnaud Delobelle <arnodel@gmail.com> - 2011-10-27 11:36 +0100
  Re: __dict__ attribute for built-in types Duncan Booth <duncan.booth@invalid.invalid> - 2011-10-27 11:03 +0000
    Re: __dict__ attribute for built-in types Chris Angelico <rosuav@gmail.com> - 2011-10-28 00:25 +1100
      Re: __dict__ attribute for built-in types Duncan Booth <duncan.booth@invalid.invalid> - 2011-10-27 14:36 +0000
        Re: __dict__ attribute for built-in types Chris Angelico <rosuav@gmail.com> - 2011-10-28 09:39 +1100
    Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-27 16:01 +0200
      Re: __dict__ attribute for built-in types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-10-27 22:19 +0000
        Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 00:52 +0200
          Re: __dict__ attribute for built-in types Terry Reedy <tjreedy@udel.edu> - 2011-10-27 22:44 -0400
          Re: __dict__ attribute for built-in types alex23 <wuwei23@gmail.com> - 2011-10-27 19:48 -0700
          Re: __dict__ attribute for built-in types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-10-28 08:01 +0000
            Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 12:03 +0200
            Re: __dict__ attribute for built-in types Christian Heimes <lists@cheimes.de> - 2011-10-28 13:51 +0200
          Re: __dict__ attribute for built-in types Peter Pearson <ppearson@nowhere.invalid> - 2011-10-28 15:52 +0000
      Re: __dict__ attribute for built-in types Hrvoje Niksic <hniksic@xemacs.org> - 2011-10-28 00:57 +0200
        Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 01:36 +0200
          Re: __dict__ attribute for built-in types MRAB <python@mrabarnett.plus.com> - 2011-10-28 01:02 +0100
            Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 04:46 +0200
              Re: __dict__ attribute for built-in types Patrick Maupin <pmaupin@gmail.com> - 2011-10-27 20:02 -0700
                Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 12:04 +0200
          Re: __dict__ attribute for built-in types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-10-28 06:21 +0000
          Re: __dict__ attribute for built-in types Hrvoje Niksic <hniksic@xemacs.org> - 2011-10-28 11:08 +0200
            Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 12:23 +0200
  Re: __dict__ attribute for built-in types Nobody <nobody@nowhere.com> - 2011-10-28 06:49 +0100

csiph-web