Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26849
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <vashkevichrb@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'parameter': 0.07; 'subject:question': 0.08; 'str,': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'anyway': 0.11; 'advance.': 0.15; '"+="': 0.16; 'subject:] ': 0.19; 'earlier': 0.21; 'x-mailer:apple mail (2.1084)': 0.22; 'cc:2**0': 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'question': 0.27; "doesn't": 0.28; 'lines': 0.28; 'prints': 0.29; 'str': 0.29; 'url:mailman': 0.29; 'function': 0.30; 'url:python': 0.32; 'subject:lists': 0.32; 'url:listinfo': 0.32; 'function.': 0.33; "can't": 0.34; 'skip:- 50': 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'similar': 0.35; 'received:209.85': 0.35; 'list.': 0.35; 'message- id:@gmail.com': 0.36; 'url:org': 0.36; 'should': 0.36; 'two': 0.37; 'why': 0.37; 'received:209': 0.37; 'header:Received:5': 0.40; 'help': 0.40; 'url:mail': 0.40; 'your': 0.60; 'header :Message-Id:1': 0.62; 'manner': 0.74; 'received:ru': 0.81 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=n04+e30Rht05Cti+uGkbJr4QrZM4yJboevfitSL+jcU=; b=eXkkvlYkLCZoHZBpyAa5zAIpaYE/jA7hc3l5dXVPU6S1bxCCgLKbQe6T1b9Ejo/b49 GLd9lCvFR0iokTP/a6KsbI1FsoUqDSKWXhi5jQGYFNToW9P8VBaGRYL4lHumPXZVzdcu 4brky358nqA79ARiudA4hXUsXbFtU8UvR3BRhpq4QR+IkZMFYpM0FgAXaRXRH1iB1XdZ EU51KhZp81SpriWNk0UVniMShRCrywqAKUDn1OR7d5UZq3AHAww8IS2xlX3KnKdXNBi4 JoaqncTznIjrp5RsD0Ktk2hvTAAHxxZ04gW0z5oSTHhxYdFapmiw8bgfH9XC1n7Vrbl7 NjPA== |
| Subject | Re: [newbie] A question about lists and strings |
| Mime-Version | 1.0 (Apple Message framework v1084) |
| Content-Type | text/plain; charset=koi8-r |
| From | Roman Vashkevich <vashkevichrb@gmail.com> |
| In-Reply-To | <k02jn0$id2$1@news.albasani.net> |
| Date | Fri, 10 Aug 2012 13:28:57 +0400 |
| Content-Transfer-Encoding | quoted-printable |
| References | <k02jn0$id2$1@news.albasani.net> |
| To | Mok-Kong Shen <mok-kong.shen@t-online.de> |
| X-Mailer | Apple Mail (2.1084) |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3146.1344590943.4697.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1344590943 news.xs4all.nl 6940 [2001:888:2000:d::a6]:52915 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26849 |
Show key headers only | View raw
10.08.2012, в 13:19, Mok-Kong Shen написал(а): > > In an earlier question about lists, I was told about the issue of > creation of local names in a function. However, I still can't > understand why the program below outputs: > > [999] sss > [999] > > and not two identical lines of output. For both operators "+=" should > anyway work in similar manner in the function xx in my view. > > Thanks for your help in advance. > > M. K. Shen > > ---------------------------------------------------------- > > def xx(list,str): > list+=[999] > str+="sss" > > lista=[] > stra="" > lista+=[999] > stra+="sss" > print(lista,stra) > > listb=[] > strb="" > xx(listb,strb) > print(listb,strb) > -- > http://mail.python.org/mailman/listinfo/python-list It seems like your xx() function doesn't return local str parameter and prints the global empty str, whereas it mutates the global list. Roman
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 11:19 +0200
Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 13:28 +0400
Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 13:48 +0400
Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:12 +0200
Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 20:37 +1000
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:37 -0400
Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 14:56 +0400
Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 13:08 +0200
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:56 -0400
Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 21:00 +1000
Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 15:06 +0400
Re: [newbie] A question about lists and strings Peter Otten <__peter__@web.de> - 2012-08-10 11:59 +0200
Re: [newbie] A question about lists and strings Rotwang <sg552@hotmail.co.uk> - 2012-08-10 16:12 +0100
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:07 -0400
Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:31 +0200
Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 20:40 +1000
Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:48 +0200
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:58 -0400
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:53 -0400
csiph-web