Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'skip:[ 20': 0.04; 'subject:bug': 0.07; 'e.g.,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.18; 'version.': 0.19; 'header:User-Agent:1': 0.23; 'developing': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'asked': 0.31; 'program,': 0.31; '>>>>': 0.31; 'received:132': 0.31; 'url:python': 0.33; 'running': 0.33; 'problem.': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:3': 0.61; 'course': 0.61; 'simple': 0.61; 'times': 0.62; 'email addr:gmail.com': 0.63; 'transferred': 0.68 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Wolfgang Maier Subject: Re: A bug? Date: Mon, 27 Oct 2014 17:17:57 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: px1.ruf.uni-freiburg.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414426664 news.xs4all.nl 2895 [2001:888:2000:d::a6]:44712 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79795 On 10/27/2014 05:01 PM, umatrp@gmail.com wrote: > I use python 3.4.0 version. In the course of developing / running a python program, I have encountered a problem. I have reproduced below a simple program to bring it out. > > >>>> d = [[0]*3]*4 >>>> dd = [1,2,3,4,5,6,7,8,9,10,11,12] >>>> for i in range(4): > ... for j in range(3): d[i][j] = dd[i*3+j] > ... >>>> d > [[10, 11, 12], [10, 11, 12], [10, 11, 12], [10, 11, 12]] >>>> > d is not transferred to dd as expected? > Of course I can use 'append' & do my job (less elegantly though). > See https://docs.python.org/3/library/stdtypes.html?highlight=list#common-sequence-operations under Note 2 . Also asked and answered multiple times at stackoverflow, e.g., http://stackoverflow.com/questions/6688223/