Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'raises': 0.07; 'immutable': 0.09; '"some': 0.16; '-tkc': 0.16; ':-/': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'object()': 0.16; 'value"': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'python?': 0.18; '>>>': 0.20; '"",': 0.22; 'pass': 0.22; "i've": 0.24; 'header:In-Reply-To:1': 0.24; '(most': 0.24; 'subject:other': 0.29; 'subject:all': 0.32; 'class': 0.33; 'instances': 0.33; 'traceback': 0.33; 'file': 0.34; 'to:addr :python-list': 0.35; 'something': 0.35; 'received:10': 0.37; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'doing': 0.38; 'wanted': 0.39; 'to:addr:python.org': 0.39; 'why': 0.40; 'bag': 0.76; 'subject:have': 0.80; "'object'": 0.84; 'received:23': 0.84; 'subject:you': 0.88 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1432328085730:3640607011 X-MC-Ingress-Time: 1432328085730 Date: Fri, 22 May 2015 15:55:16 -0500 From: Tim Chase To: python-list@python.org Subject: Re: Ah Python, you have spoiled me for all other languages In-Reply-To: <87k2w0mjvc.fsf@elektro.pacujo.net> References: <555f440a$0$12990$c3e8da3$5496439d@news.astraweb.com> <201505221914.t4MJE3e9009120@fido.openend.se> <555F84CD.9010204@mrabarnett.plus.com> <87k2w0mjvc.fsf@elektro.pacujo.net> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AuthUser: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432328491 news.xs4all.nl 2870 [2001:888:2000:d::a6]:34296 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91074 On 2015-05-22 23:34, Marko Rauhamaa wrote: > >>> object().x = 3 > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'object' object has no attribute 'x' > > Why are object instances immutable in Python? I've wondered this on multiple occasions, as I've wanted to just make an attribute bag and have to do something like class AttrBag(object): pass ab = AttrBag() ab.x = 42 ab.y = "some other value" because just doing ab = object() raises the AttributeError Marko highlights. :-/ -tkc