Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.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.root@sequans.com> References: <1793477354.3492917.1351526431192.JavaMail.root@sequans.com> Date: Mon, 29 Oct 2012 16:12:29 +0000 Subject: Re: Immutability and Python From: andrea crotti To: Jean-Michel Pichavant Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list 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: 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: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32391 2012/10/29 Jean-Michel Pichavant : > > > 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..