Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'explicitly': 0.04; 'context': 0.05; 'say,': 0.05; '*not*': 0.07; 'expressions': 0.07; 'seemed': 0.07; 'python': 0.09; '(although': 0.09; 'array.': 0.09; 'c/c++': 0.09; 'consistency.': 0.09; 'explanation': 0.09; 'immutable': 0.09; 'iterate': 0.09; 'stated.': 0.09; 'supported.': 0.09; 'url:github': 0.09; 'worse': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.11; '*less*': 0.16; 'background,': 0.16; 'holy': 0.16; 'intuition': 0.16; 'libs': 0.16; 'opposite': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.17; 'causing': 0.20; 'bit': 0.21; 'subject:skip:i 10': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'programming': 0.23; 'cc:no real name:2**0': 0.24; 'external': 0.24; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; '(which': 0.26; 'question': 0.27; 'possible,': 0.27; 'received:209.85.210.46': 0.27; 'skip:@ 10': 0.27; 'interface': 0.27; 'subject:list': 0.28; 'represent': 0.28; 'behaviour': 0.29; "d'aprano": 0.29; 'dimensions': 0.29; 'mind,': 0.29; "people's": 0.29; 'steven': 0.29; 'this.': 0.29; "i'm": 0.29; 'up.': 0.31; 'code': 0.31; 'point': 0.31; 'generally': 0.32; 'quickly': 0.32; 'likely': 0.33; 'another': 0.33; 'agree': 0.34; 'received:google.com': 0.34; 'list': 0.35; 'fail': 0.35; 'pm,': 0.35; 'received:192.168.0': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'message-id:@gmail.com': 0.36; "wasn't": 0.36; "didn't": 0.36; 'should': 0.36; 'charset:us- ascii': 0.36; 'being': 0.37; 'why': 0.37; 'passed': 0.37; 'skip:4 10': 0.37; 'skip:z 10': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'degree': 0.38; 'sure': 0.38; 'received:192': 0.39; 'easily': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'most': 0.61; 'places': 0.61; 'header:Message-Id:1': 0.62; 'truly': 0.62; 'production': 0.63; 'different': 0.63; 'more': 0.63; 'making': 0.64; 'become': 0.65; 'treat': 0.65; 'touch': 0.69; 'online': 0.70; 'born': 0.71; 'obvious': 0.71; "everything's": 0.84; 'perceive': 0.84; 'received:192.168.0.100': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=LKgYfjhozWEMbNDy1W6mPEWAiCZyzIJyNdxbBOrtsXc=; b=qoWhzJjyw1WRE6VywUJ63kvjcc2eBA6AE1z5U/hKmPOk9O4C+xlNsXqU+lpRGckgju vJ7fLpHkJBpGRHGQk+7OnU77oLcThskbFz0qW9aH6ioaHUWVye47c8DgaJUyMwCqGaye mdOHrvNa1y6e+GvlB0niKXSKO1NhaDTnOEGkdg9QzZg/66Hc6BBPOxKz8EKCuA20R/eg uV9MCvvCND2GTpVJzpVT5k9NDsBnYgv+my1lYB+CsHO1cs5bisAwuM3PPpqWq34j7uxx /+bIklcg+9EMDLmGY7UyqcrUWsF2WejBnzAylWmk+HXI/gFG/dHKuaJcbXxaddxgKd6q WZWA== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: Multi-dimensional list initialization From: Demian Brecht In-Reply-To: <5099bf7d$0$29980$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 6 Nov 2012 22:56:33 -0800 Content-Transfer-Encoding: quoted-printable References: <50978323$0$6908$e4fe514c@news2.news.xs4all.nl> <5098d2ac$0$29980$c3e8da3$5496439d@news.astraweb.com> <5099bf7d$0$29980$c3e8da3$5496439d@news.astraweb.com> To: Steven D'Aprano X-Mailer: Apple Mail (2.1499) 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: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352271397 news.xs4all.nl 6874 [2001:888:2000:d::a6]:55660 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32876 On 2012-11-06, at 5:55 PM, Steven D'Aprano = wrote: > I'm not entirely sure what your point is here. The OP screwed up -- he=20= > didn't generate a 4-dimensional array. He generated a 2-dimensional=20 > array. If his intuition about the number of dimensions is so poor, why=20= > should his intuition about list multiplication be treated as = sacrosanct? Yep, I may have mis-worded the explanation a bit (although I *did* = express that it was a 4D matrix in the OP). I was using a 2D list to = represent a 4D matrix in order to easily iterate over 90 degree = rotations with zip(*matrix[::-1]). It wasn't for production code = (otherwise I *would* be using numpy), it was for an online programming = challenge in which external libs are not supported. > As they say, the only truly intuitive interface is the nipple. There = are=20 > many places where people's intuition about programming fail. And many=20= > places where Fred's intuition is the opposite of Barney's intuition. I couldn't agree more with this. My question was *not* based on what I = perceive to be intuitive (although most of this thread has now seemed to = devolve into that and become more of a philosophical debate), but was = based on what I thought may have been inconsistent behaviour (which was = quickly cleared up with None being immutable and causing it to *seem* = that the behaviour was inconsistent to the forgetful mind). As you touch = on here, "intuition" is entirely subjective. If you're coming from a = C/C++ background, I'd think that your intuition would be that = everything's passed by value unless explicitly stated. Someone coming = from another background (Lua perhaps?) would likely have entirely = different intuition. > So while I prefer intuitively obvious behaviour where possible, it is = not=20 > the holy grail, and I am quite happy to give it up. I fail to see where there has been any giving up on intuitiveness in the = context of this particular topic. In my mind, intuitiveness is generally = born of repetitiveness and consistency. As everything in Python is a = reference, it would seem to me to be inconsistent to treat expressions = such as [[obj]*4]*4 un-semantically (Pythonically speaking) and making = it *less* intuitive. I agree that Python would definitely be worse off. Demian Brecht @demianbrecht http://demianbrecht.github.com