Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; "subject:' ": 0.07; 'classes.': 0.09; 'def': 0.12; 'behave': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'immutability': 0.16; 'mutability': 0.16; 'rules.': 0.16; 'user-defined': 0.16; 'wrote:': 0.18; 'things.': 0.19; 'header:In-Reply-To:1': 0.27; 'on,': 0.29; 'sets': 0.30; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'skip:_ 10': 0.34; 'received:google.com': 0.35; 'false': 0.36; 'done': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'break': 0.61; "you've": 0.63; 'assistance': 0.66; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=AG89Nw+gP0S146luh682sSGsgSPK/oP+jcN92mm9LSo=; b=MMyeY3HUYjnqqG6MvThnkA6Rb1QpwfMnU9u42jgYFf9tEMO7i6ociJ4L6OcVYKUqDV vKtdLVkihxTYTE0bjAhEuziR+gb8dT6RJZEVRsXfXuyEUWDrMIW9fO5rhx7k2T1tgGki OFWC/1uMu/58AxSbORx5462uXZxow4KUu3obDYR7wsrV/tzswnGxZ6lCyLyswuND3AyS nQR4qTQ8Djo4QEmv/LJ6FezESDQsFr8uwAIYLij7M7h3RHcRgDD3dRKrAVZQAR5D6CBb g6jE6VLaTuRjmcnuvNazH/PaPnNxjmT+nr2T+TwmqSMxN+8Ln/W8sHiYoJn+RB/47KQd KEPg== MIME-Version: 1.0 X-Received: by 10.66.122.66 with SMTP id lq2mr714277pab.183.1384248060124; Tue, 12 Nov 2013 01:21:00 -0800 (PST) In-Reply-To: References: <1384206048.30461.46091021.634F0FCA@webmail.messagingengine.com> Date: Tue, 12 Nov 2013 20:21:00 +1100 Subject: Re: 'isimmutable' and 'ImmutableNester' From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 1384248069 news.xs4all.nl 15980 [2001:888:2000:d::a6]:46943 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59168 On Tue, Nov 12, 2013 at 8:12 PM, Frank-Rene Sch=E4fer w= rote: > (1) hash()-ability !=3D immutability (!) > > Proof: > > class X: > def __hash__(self): return 0 > x =3D=3D y !=3D y =3D=3D x Proof: class X: def __eq__(self,other): return True class Y: def __eq__(self,other): return False All you've done is proven that you can subvert things. By fiddling with __hash__, __eq__, and so on, you can make sets and dicts behave very oddly. Means nothing. Fundamentally, your mutability check is going to need some form of assistance from user-defined classes. That means a class can break your rules. ChrisA