Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'assignment': 0.07; 'odd': 0.07; 'cc:addr:python-list': 0.11; 'mutated': 0.16; 'top-level': 0.16; 'exception': 0.16; 'sat,': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'basically': 0.19; 'cc:addr:python.org': 0.22; 'exists': 0.24; 'cc:2**0': 0.24; 'first,': 0.26; 'shown': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'raised': 0.31; 'probably': 0.32; 'not.': 0.33; 'received:google.com': 0.35; 'add': 0.35; 'possible': 0.36; 'should': 0.36; 'whatever': 0.38; 'does': 0.39; 'even': 0.60; 'remove': 0.60; 'results.': 0.60; 'such': 0.63; 'happen': 0.63; 'to:addr:gmail.com': 0.65; 'mar': 0.68; 'wish,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=UcfVknsSPuU7C94xqIwvp0BqG9VjaJvoToT3+EL8Ulk=; b=Ca1AU42J7JNRULyiIETjlpBZJP0S9ghRs8cGIfWxvfKCtj6KoZZdd0rJKUvaVGwYyr XkSktOg7WKU4RX0M3iBchkVb6wcn2e5PQUVgsZ7/q8kPNuRPrbzaljLOzZtFsjYiq9M6 zea+pC3FIsj3cWCeFfWRFo2A2J/5/MzYa/fmtWnKUdwiE3i0DfZcjMXLgKYprq/Bi1IH 67Zww19GIQl2/HdwiKfaA1mLlko/fGJ0pRcyIeeub+tAeFGHg61sZezLa2s7f2ycGHC7 yIQaZBzeSZ6I6Nnv0dlPPTwbzSbjXfwtpJJgzCpDgWVtqV6Xda13zfuNz0eTFl73WjU/ 1PEw== X-Received: by 10.112.150.233 with SMTP id ul9mr6204771lbb.2.1394387726733; Sun, 09 Mar 2014 10:55:26 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: References: From: Joshua Landau Date: Sun, 9 Mar 2014 17:54:46 +0000 X-Google-Sender-Auth: tWNPD0PjhMWtQ0KneX8tCgUFR2M Subject: Re: Tuples and immutability To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394388173 news.xs4all.nl 2966 [2001:888:2000:d::a6]:37192 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68084 On 28 February 2014 14:43, Chris Angelico wrote: > On Sat, Mar 1, 2014 at 1:41 AM, Joshua Landau wrote: >> Would it be better to add a check here, such that if this gets raised >> to the top-level it includes a warning ("Addition was inplace; >> variable probably mutated despite assignment failure")? > > That'd require figuring out whether or not the variable was actually > mutated, and that's pretty hard to work out. It does not. First, the "warning" is actually an attachment to the exception so is only shown if the exception is uncaught. This should basically never happen in working code. The warning exists only to remove likely misunderstanding in these odd cases. Even if "x = (1,); x[0] += 1" warned "addition was inplace; possible mutation occurred" or whatever phrasing you wish, this would only cause a quick check of the results.