Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26857
| Date | 2012-08-10 06:37 -0400 |
|---|---|
| From | Dave Angel <d@davea.name> |
| Subject | Re: [newbie] A question about lists and strings |
| References | <k02jn0$id2$1@news.albasani.net> <39A401F0-12DD-464F-A0D1-639C56FA48A0@gmail.com> <mailman.3148.1344592099.4697.python-list@python.org> <k02mpk$p0e$1@news.albasani.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3152.1344595069.4697.python-list@python.org> (permalink) |
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
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