Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'languages,': 0.04; 'subject:Python': 0.05; 'modify': 0.05; 'mutable': 0.09; 'cc:addr:python-list': 0.10; 'caring': 0.16; 'tend': 0.17; 'creates': 0.18; 'received:209.85.214.174': 0.21; 'object.': 0.22; 'operations.': 0.22; 'cc:2**0': 0.23; 'example': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'object,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; "i'm": 0.29; 'maybe': 0.29; 'point': 0.31; 'impression': 0.33; 'safely': 0.33; 'operations': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'functional': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'sure': 0.38; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'more': 0.63; 'compose': 0.84; 'worth,': 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=jmaUAcHeWmeZ0vYy7FB6x2s4pIaCH+2zqvMxsGkpawc=; b=VUSkIKYMrws2bYDN3du/QGLW6P/Nmh61FZUtBtMkYK4LcSq5aWd7YPaMkkTq0DFfty 70huey257ICGaS8n+MLDu5L+NnTbqPqrypyJlZI/OLOtjNzEILr/WygBxwGNqNKZipEf b8ZLPINXs5nq0WUUr54YzcV288/ZI+mofjqG50dcUHTtwyggxt8Sahxx4bFK3hD/Xz0o kfBNzNozKdKMOE192YoR5Xm7vLFzyTNi7bT2piiYs/jVxXS7brRVZD55hGHXYEu2ieKG GEchpTo9AJm6IbH9OpWo9vj+ChMnvNC1HYBDwxn0QzpwvdjHmLNWho+1QyNYSqgMd7uH PZ/Q== MIME-Version: 1.0 In-Reply-To: <771101937.3475467.1351525139677.JavaMail.root@sequans.com> References: <771101937.3475467.1351525139677.JavaMail.root@sequans.com> Date: Mon, 29 Oct 2012 15:44:31 +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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351525475 news.xs4all.nl 6925 [2001:888:2000:d::a6]:37578 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32385 2012/10/29 Jean-Michel Pichavant : > > "return NumWrapper(self.number + 1) " > > still returns a(nother) mutable object. > > So what's the point of all this ? > > JM > Well sure but it doesn't modify the first object, just creates a new one. There are in general good reasons to do that, for example I can then compose things nicely: num.increment().increment() or I can parallelize operations safely not caring about the order of operations. But while I do this all the time with more functional languages, I don't tend to do exactly the same in Python, because I have the impression that is not worth, but maybe I'm wrong..