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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:: [': 0.03; 'output': 0.04; 'subject:question': 0.08; 'arguments,': 0.09; 'differently.': 0.09; 'explanation': 0.09; 'follows.': 0.09; 'happens.': 0.09; 'cc:addr:python-list': 0.10; '>the': 0.16; 'concatenated': 0.16; 'immutable,': 0.16; 'mutated': 0.16; 'nonetheless': 0.16; 'string': 0.17; 'wrote:': 0.17; 'creates': 0.18; 'subject:] ': 0.19; 'parameters': 0.20; 'cc:2**0': 0.23; 'statement': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; 'parameters.': 0.29; 'str': 0.29; 'returned': 0.30; 'function': 0.30; 'lists': 0.31; 'subject:lists': 0.32; 'print': 0.32; 'right?': 0.33; 'thanks': 0.34; 'list': 0.35; 'expected': 0.35; 'but': 0.36; 'passed': 0.37; 'nothing': 0.38; 'takes': 0.39; 'received:192': 0.39; 'called': 0.39; 'received:192.168': 0.40; 'different': 0.63; 'more': 0.63; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84; 'dealt': 0.91; 'str.': 0.91 Date: Fri, 10 Aug 2012 06:37:26 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Mok-Kong Shen Subject: Re: [newbie] A question about lists and strings References: <39A401F0-12DD-464F-A0D1-639C56FA48A0@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:pFSDb3FzSPpNZTIstygGqDp7z5J1DIgr5cqeKUgfC1y JEd6tIMPTNFjWXdS7KPknyMq5gmda0aNIB/YpL/i7DmTT/wf9I vueLF4GlxSY6huuiO9GClzraXgYX/7sMHlq6XoSG3d4QQwy3FY 3lRV4xmt7io0Ry3BBPtj4l9EXpDoZgk7rZtBi8KOk9XHYdSB8m ggtgG5dwfy3QxSeheMsKj83y2yvkYNtpBSyfuen86Hm2+Y7eB9 E49CspF7T9BH6a7CgqTFdILrt4x6Z55nUTLghx/l1rUTtXosm5 Kyic1CTAODYw4CEBbSiTmrG3SUJwuo5bXKIjuPpcwXENw4CcA= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name 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: 1344595069 news.xs4all.nl 6913 [2001:888:2000:d::a6]:55538 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26857 On 08/10/2012 06:12 AM, Mok-Kong Shen wrote: > Am 10.08.2012 11:48, schrieb Roman Vashkevich: >> [snip] > >The function .... It takes list by reference and creates a new local > > str. When it's called with listb and strb arguments, listb is passed > > by reference and mutated. A string "sss" is concatenated with an > > empty local str. Nothing more happens. Since local str is not > > returned by xx(), it can not be expected to be printed out in the > > statement that follows. What is printed out in the print statement is > > the mutated listb and the global strb. > > Thanks for the explanation of the output obtained. But this means > nonetheless that parameters of types lists and strings are dealt with > in "inherently" (semantically) different ways by Python, right? > > M. K. Shen > Nothing to do with parameters. Lists are mutable, and strings are immutable, so += behaves differently. -- DaveA