On 04.09.2015 05:36, random...@fastmail.us wrote:
You haven't demonstrated that the RHS is affected by anything. The
sample code in the original post of this thread behaves identically if
the RHS is a simple tuple of (2, 1) [or (1, 2)] respectively. If you
have another sample that shows differe
On Thu, Sep 3, 2015, at 19:25, Sven R. Kunze wrote:
> You mentioned side-effects. That is true. Right now, however, the
> side-effects even fire back to the RHS of the assignment. That is really
> weird. To me, and as it seems to some other folks here, the RHS should
> be at least independent
On Fri, Sep 4, 2015 at 9:25 AM, Sven R. Kunze wrote:
> Both sides may have side-effects, but at least independently from each
> other. That's at least how I feel about it.
You can't do that, though. Every piece of Python code can cause
arbitrary code to execute, and unless you run them in separat
On 03.09.2015 03:17, random...@fastmail.us wrote:
The question is what does "assign it to the left side at once" even
*mean* in the presence of subscripts? Build up a list of
object-subscript pairs (evaluating all the subscripts, including if any
may have side effects) before executing any __set
On Sep 2, 2015 7:51 PM, "Steven D'Aprano" wrote:
>
> What's the alternative? I asked this question earlier, and got no answer --
> apparently at least three people prefer behaviour that they cannot explain
> how to get the results they want :-)
>
> As far as I am concerned, having both of these:
>
On Thu, 3 Sep 2015 04:06 am, Ian Kelly wrote:
> On Wed, Sep 2, 2015 at 11:42 AM, Terry Reedy wrote:
>> On 9/2/2015 6:01 AM, Antoon Pardon wrote:
>>>
>>>
>> a = [1, 2, 3, 4, 5]
>> b = 1
>> b, a[b] = a[b], b
>> a
>>>
>>> [1, 2, 1, 4, 5]
[...]
> I do. I think the former behavior is
On Wed, Sep 2, 2015, at 13:26, Sven R. Kunze wrote:
> I agree as well. First evaluate the right side, then assign it to the
> left side at once.
The behavior, if it's *not* "first evaluating the right side", is
indistinguishable from it by this test. Assigning the RHS of each case
to a separate l
b, a[b] = a[b], b
Nice. If I ever notice that kind of code in our codebase I'll 1)
check file history to find out the "author" 2) ask that guy to remove
it immediately :-)
Vladimir
http://itunes.apple.com/us/app/python-code-samples/id1025613117
--
https://mail.python.org/mailman/listinf
On 02.09.2015 19:42, Terry Reedy wrote:
On 9/2/2015 6:01 AM, Antoon Pardon wrote:
a = [1, 2, 3, 4, 5]
b = 1
b, a[b] = a[b], b
a
[1, 2, 1, 4, 5]
a = [1, 2, 3, 4, 5]
b = 1
a[b], b = b, a[b]
a
[1, 1, 3, 4, 5]
I think I understand how it gets these results
but I'm not really happy with them. I
On Wed, Sep 2, 2015 at 11:42 AM, Terry Reedy wrote:
> On 9/2/2015 6:01 AM, Antoon Pardon wrote:
>>
>>
> a = [1, 2, 3, 4, 5]
> b = 1
> b, a[b] = a[b], b
> a
>>
>> [1, 2, 1, 4, 5]
>
> a = [1, 2, 3, 4, 5]
> b = 1
> a[b], b = b, a[b]
> a
>>
>> [1, 1, 3, 4, 5]
>>
>>
On 9/2/2015 6:01 AM, Antoon Pardon wrote:
a = [1, 2, 3, 4, 5]
b = 1
b, a[b] = a[b], b
a
[1, 2, 1, 4, 5]
a = [1, 2, 3, 4, 5]
b = 1
a[b], b = b, a[b]
a
[1, 1, 3, 4, 5]
I think I understand how it gets these results
but I'm not really happy with them. I think python
should give the second resu
On 9/2/2015 8:26 AM, Steven D'Aprano wrote:
On Wed, 2 Sep 2015 08:01 pm, Antoon Pardon wrote:
a = [1, 2, 3, 4, 5]
b = 1
b, a[b] = a[b], b
a
[1, 2, 1, 4, 5]
Equivalent to:
temp1 = a[b] # a[1] == 2
temp2 = b # 1
b = temp1 # b = 2
a[b] = temp2 # a[2] = 1
Or using a queue (FIFO) rather
I agree as well. First evaluate the right side, then assign it to the
left side at once.
On 02.09.2015 12:22, Nick Sarbicki wrote:
That's interesting. I agree with you, I'd prefer the second result in
both cases.
But makes sense as it evaluates left to right and seems to break up
the unpacki
On 02/09/2015 11:01, Antoon Pardon wrote:
a = [1, 2, 3, 4, 5]
b = 1
b, a[b] = a[b], b
a
[1, 2, 1, 4, 5]
a = [1, 2, 3, 4, 5]
b = 1
a[b], b = b, a[b]
a
[1, 1, 3, 4, 5]
I think I understand how it gets these results
but I'm not really happy with them. I think python
should give the second resu
On Wed, Sep 2, 2015 at 11:59 PM, Antoon Pardon
wrote:
>> But if you're confused by
>> it, there's a simple solution: Don't reference the same "thing" more
>> than once on the LHS.
>
> That is rather extreme. It would mean we avoid the following:
>
> a[i], b[i] = b[i], a[i] # references i twice on
Op 02-09-15 om 14:45 schreef Chris Angelico:
> On Wed, Sep 2, 2015 at 10:26 PM, Steven D'Aprano wrote:
>>> I think I understand how it gets these results
>>> but I'm not really happy with them. I think python
>>> should give the second result in both cases.
>> Apart from breaking backwards compati
On Wed, Sep 2, 2015 at 10:26 PM, Steven D'Aprano wrote:
>> I think I understand how it gets these results
>> but I'm not really happy with them. I think python
>> should give the second result in both cases.
>
> Apart from breaking backwards compatibility, how would you implement such a
> thing? A
On Wed, 2 Sep 2015 08:01 pm, Antoon Pardon wrote:
>
a = [1, 2, 3, 4, 5]
b = 1
b, a[b] = a[b], b
a
> [1, 2, 1, 4, 5]
Equivalent to:
temp1 = a[b] # a[1] == 2
temp2 = b # 1
b = temp1 # b = 2
a[b] = temp2 # a[2] = 1
Or using a queue (FIFO) rather than temp variables:
push
That's interesting. I agree with you, I'd prefer the second result in both
cases.
But makes sense as it evaluates left to right and seems to break up the
unpacking into separate statements.
Could be useful if you want to hold the results of a generator in sequence,
can call the same function mult
>>> a = [1, 2, 3, 4, 5]
>>> b = 1
>>> b, a[b] = a[b], b
>>> a
[1, 2, 1, 4, 5]
>>> a = [1, 2, 3, 4, 5]
>>> b = 1
>>> a[b], b = b, a[b]
>>> a
[1, 1, 3, 4, 5]
I think I understand how it gets these results
but I'm not really happy with them. I think python
should give the second result in both cases
20 matches
Mail list logo