On 10/08/2012 10:59, Peter Otten wrote:
[...]
If you have understood the above here's a little brain teaser:
a = ([1,2,3],)
a[0] += [4, 5]
Traceback (most recent call last):
File "", line 1, in
TypeError: 'tuple' object does not support item assignment
a[0]
What are the contents of a[
Am 10.08.2012 12:56, schrieb Roman Vashkevich:
I am not sure I understand your question. Can you rephrase it or make it more
explicit?
I have just detailed my problem and Dave Angel has shown how to solve
it properly.
M. K. Shen
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Aug 10, 2012 at 8:56 PM, Dave Angel wrote:
>> On Fri, Aug 10, 2012 at 8:07 PM, Dave Angel wrote:
>>> But if you said c=651 and d=651, you'd have two
>>> objects, and the two names would be bound to different objects, with
>>> different ids.
>> To be more accurate, you *may* have two diff
10.08.2012, в 14:12, Mok-Kong Shen написал(а):
> 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
On 08/10/2012 06:48 AM, Mok-Kong Shen wrote:
> Am 10.08.2012 12:40, schrieb Chris Angelico:
>
>> But it's probably worth thinking about exactly why you're wanting to
>> change that string, and what you're really looking to accomplish.
>> There may well be a better way.
>
> My problem is the followi
On 08/10/2012 06:37 AM, Chris Angelico wrote:
> On Fri, Aug 10, 2012 at 8:12 PM, Mok-Kong Shen
> wrote:
>> 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
10.08.2012, в 14:12, Mok-Kong Shen написал(а):
> 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
On 08/10/2012 06:31 AM, Mok-Kong Shen wrote:
> Am 10.08.2012 12:07, schrieb Dave Angel:
> [snip]
>> At this point, in top-level code, the listb object has been modified,
>> and the strb one has not; it still is bound to the old value.
>
> This means there is no way of modifying a string at the top
Am 10.08.2012 12:40, schrieb Chris Angelico:
But it's probably worth thinking about exactly why you're wanting to
change that string, and what you're really looking to accomplish.
There may well be a better way.
My problem is the following: I have at top level 3 lists and 3 strings:
lista, lis
On Fri, Aug 10, 2012 at 8:31 PM, Mok-Kong Shen
wrote:
> This means there is no way of modifying a string at the top level
> via a function, excepting through returning a new value and assigning
> that to the string name at the top level. Please again correct me, if
> I am wrong.
Yes, but you can
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 co
On Fri, Aug 10, 2012 at 8:12 PM, Mok-Kong Shen
wrote:
> 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?
It's nothing to do with parameters, b
Am 10.08.2012 12:07, schrieb Dave Angel:
[snip]
At this point, in top-level code, the listb object has been modified,
and the strb one has not; it still is bound to the old value.
This means there is no way of modifying a string at the top level
via a function, excepting through returning a ne
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 ha
On 08/10/2012 05:19 AM, Mok-Kong Shen wrote:
>
> 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 op
Mok-Kong Shen wrote:
>
> 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
10.08.2012, в 13:28, Roman Vashkevich написал(а):
> 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]
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 b
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 fu
19 matches
Mail list logo