Message from discussion
Immutability and Python
Received: by 10.66.75.39 with SMTP id z7mr3971147pav.26.1352126780065;
Mon, 05 Nov 2012 06:46:20 -0800 (PST)
Path: 6ni62650pbd.1!nntp.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-hub.siol.net!news.mi.ras.ru!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path: <andrea.crott...@gmail.com>
X-Original-To: python-l...@python.org
Delivered-To: python-l...@mail.python.org
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02;
'subject:Python': 0.05; 'modify': 0.05; 'python': 0.09; 'dict':
0.09; 'immutable': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10;
'suggest': 0.11; 'language': 0.14; 'immutable,': 0.16;
'instance,': 0.17; 'python?': 0.20; 'trying': 0.21; 'meant': 0.21;
'received:209.85.214.174': 0.21; 'cc:2**0': 0.23; 'example': 0.23;
'this:': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1':
0.25; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'post':
0.28; 'dictionary': 0.29; 'oop': 0.29; 'objects': 0.29; 'skip:_
10': 0.29; 'class': 0.29; "i'm": 0.29; 'languages': 0.33;
'received:google.com': 0.34; 'expected': 0.35; 'received:209.85':
0.35; 'add': 0.36; 'really': 0.36; 'but': 0.36; 'functional':
0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38;
'apply': 0.39; 'received:209.85.214': 0.39; 'header:Received:5':
0.40; 'think': 0.40; 'your': 0.60; 'first': 0.61; 'necessarily':
0.63; 'skip:n 10': 0.63; 'state.': 0.71; 'doi': 0.84
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
:cc:content-type;
bh=LG6zJtWCuGOEWKjQ4qS5GTRQfFx31KN3g/skg9ygm58=;
b=AFvgTXHi3AC1eTnFCknwWW5nlgmTaQz9kLlgGZ+t+K5YFUD0BmwUGu1+5G0RG1VaZT
oILA9WbZ8A8IQWM6WLTKu+swV8tYrSujdIxc8QIknNMoP7mBy9Eo5iFp3VcC6Q+Cwu7f
+UCBOh0p4sgmUw+VIfoUNEduVh0gXhU5zDlLSCGcqhUz4Lkue5orriXtv8TJufCGFcEN
1OUDqTKl8e9EhleDrU/Fo0OJ/vkLhC/xSij8qy15lBkgVWRiLKWiE6YI9cJfVFHKjXm6
pI7+qnwolmxlkYMAhFgBBEH8tSTm1tmcKHfS6UmMynkvKNdTueyxXI50/D5B70AABn6P
pkOw==
MIME-Version: 1.0
In-Reply-To: <1793477354.3492917.1351526431192.JavaMail.r...@sequans.com>
References: <CAF_E5Jbf0KJjDLV0jS-p_J9E4D8=_sPScgE+vkmkN2sMw=3...@mail.gmail.com>
<1793477354.3492917.1351526431192.JavaMail.r...@sequans.com>
Date: Mon, 29 Oct 2012 16:12:29 +0000
Subject: Re: Immutability and Python
From: andrea crotti <andrea.crott...@gmail.com>
To: Jean-Michel Pichavant <jeanmic...@sequans.com>
Cc: python-list <python-l...@python.org>
X-BeenThere: python-l...@python.org
X-Mailman-Version: 2.1.15
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-requ...@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-l...@python.org>
List-Help: <mailto:python-list-requ...@python.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-requ...@python.org?subject=subscribe>
Newsgroups: comp.lang.python
Message-ID: <mailman.3025.1351527152.27098.python-l...@python.org>
Lines: 27
NNTP-Posting-Host: 2001:888:2000:d::a6
X-Trace: 1351527152 news.xs4all.nl 6887 [2001:888:2000:d::a6]:36386
X-Complaints-To: ab...@xs4all.nl
Bytes: 4430
X-Received-Bytes: 4478
Content-Type: text/plain; charset=ISO-8859-1
2012/10/29 Jean-Michel Pichavant <jeanmic...@sequans.com>:
>
>
> In an OOP language num.increment() is expected to modify the object in place.
> So I think you're right when you say that functional languages technics do not necessarily apply to Python, because they don't.
>
> I would add that what you're trying to suggest in the first post was not really about immutability, immutable objects in python are ... well immutable, they can be used as a dict key for instance, your NumWrapper object cannot.
>
>
> JM
Yes right immutable was not the right word, I meant that as a contract
with myself I'm never going to modify its state.
Also because how doi I make an immutable object in pure Python?
But the example with the dictionary is not correct though, because this:
In [145]: class C(object):
.....: def __hash__(self):
.....: return 42
.....:
In [146]: d = {C(): 1}
works perfectly, but an object of class C can mutate as much as it
wants, as my NumWrapper instance..