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!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'instance': 0.05; '>>>>': 0.09; 'builtin': 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; '>>>': 0.18; 'int': 0.18; '(most': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'traceback': 0.24; 'typeerror:': 0.30; 'does': 0.32; 'usually': 0.32; 'to:addr :python-list': 0.33; 'header:User-Agent:1': 0.34; 'assignment': 0.34; 'last):': 0.34; 'header:X-Complaints-To:1': 0.35; 'object': 0.35; 'file': 0.36; 'received:org': 0.38; 'steven': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; '"spam"': 0.84; 'schrieb': 0.84; 'subject:types': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Christian Heimes Subject: Re: __dict__ attribute for built-in types Date: Fri, 28 Oct 2011 13:51:33 +0200 References: <4ea92dae$0$20639$426a74cc@news.free.fr> <4ea96437$0$24971$426a74cc@news.free.fr> <4ea9d8e6$0$29968$c3e8da3$5496439d@news.astraweb.com> <4ea9e0ba$0$2261$426a74cc@news.free.fr> <4eaa614b$0$29968$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: f048161000.adsl.alicedsl.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: <4eaa614b$0$29968$c3e8da3$5496439d@news.astraweb.com> X-Enigmail-Version: 1.4a1pre OpenPGP: id=AD16AB1B; url=http://cheimes.de/heimes.asc 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1319802709 news.xs4all.nl 6862 [2001:888:2000:d::a6]:43257 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15103 Am 28.10.2011 10:01, schrieb Steven D'Aprano: >>>> hasattr(int, '__dict__') # Does the int class/type have a __dict__? > True >>>> hasattr(42, '__dict__') # Does the int instance have a __dict__? > False Also __dict__ doesn't have to be an instance of __dict__. Builtin types usually have a dictproxy instane as their __dict__. >>> type(int.__dict__) >>> int.__dict__["egg"] = "spam" Traceback (most recent call last): File "", line 1, in TypeError: 'dictproxy' object does not support item assignment