Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'instance': 0.05; 'attribute': 0.07; '>>>>': 0.09; 'def': 0.15; 'to:addr:free.fr': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'cc:no real name:2**0': 0.20; '(most': 0.21; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.212.46': 0.23; 'received:mail-vw0-f46.google.com': 0.23; 'refers': 0.23; 'object,': 0.24; 'traceback': 0.24; 'random': 0.28; 'import': 0.28; 'pass': 0.29; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'objects': 0.32; "can't": 0.33; 'wondering': 0.33; 'realize': 0.34; 'received:209.85.212': 0.34; 'october': 0.34; 'last):': 0.34; 'object': 0.35; 'reasons': 0.37; 'some': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'why': 0.39; 'official': 0.40; 'where': 0.40; "'foo'": 0.84; 'candide': 0.84; 'subject:types': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=yC54pj0FRachqPVBgP+K3NMvKInp88w46nQxxefg8Pg=; b=ZiuSpVyprLoNHQ1tGU6/ldxr9+NtNTeDnukQRlXyncb0IUew0QreW1o+RE3M6v2XuV UwBiGG7RFr9FilTtgrOplLOsvRDSmeYoWyoZzJjYxRf41P5ZqZmcbnORRIhXx+rbsFcn JO5+wQZTgFb/mVIWQW1jC1EOJTY3LcqQ4Rt4c= MIME-Version: 1.0 In-Reply-To: <4ea92dae$0$20639$426a74cc@news.free.fr> References: <4ea92dae$0$20639$426a74cc@news.free.fr> Date: Thu, 27 Oct 2011 11:36:54 +0100 Subject: Re: __dict__ attribute for built-in types From: Arnaud Delobelle To: candide Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1319711816 news.xs4all.nl 6974 [2001:888:2000:d::a6]:36179 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15037 On 27 October 2011 11:08, candide wrote: > I realize that built-in types objects don't provide a __dict__ attribute = and > thereby i can't set an attribute to a such object, for instance > > >>>> a=3D[42,421] >>>> a.foo=3D"bar" > Traceback (most recent call last): > =C2=A0File "", line 1, in > AttributeError: 'list' object has no attribute 'foo' >>>> a.__dict__ > Traceback (most recent call last): > =C2=A0File "", line 1, in > AttributeError: 'list' object has no attribute '__dict__' >>>> Some built in types have a __dict__: >>> def foo(): pass ... >>> foo.__dict__ {} >>> import random >>> len(random.__dict__) 57 > > So, i was wondering : > > -- why this behaviour ? Performance reasons I guess. > -- where the official documentation refers to this point ? I don't know this one :) --=20 Arnaud