On Sat, Jun 2, 2018 at 9:10 AM, Gregory Ewing
wrote:
> Chris Angelico wrote:
>>
>> if you 'break' immediately after a mutation, that isn't
>> continuing to iterate. Even though you're inside the loop, there's no
>> further action taken to process the loop, and no problem.
>
>
> Yes, but you're als
Chris Angelico wrote:
if you 'break' immediately after a mutation, that isn't
continuing to iterate. Even though you're inside the loop, there's no
further action taken to process the loop, and no problem.
Yes, but you're also not calling next() again, so no
exception would be triggered.
My po
On Thu, 31 May 2018 16:37:39 +0200, Frank Millman wrote:
[...]
> Agreed, but my gut feel, and the following example, suggest that when
> processing the last key in a dictionary while iterating over it, you
> have not yet stopped iterating.
>
d = {}
d[1] = 'one'
d[2] = 'two'
Before
"Gregory Ewing" wrote in message news:fnccd8ff3s...@mid.individual.net...
Chris Angelico wrote:
> It is an error to mutate the dictionary *and then continue to iterate
> over it*.
But if you're processing the last key, and you add one so
that it's no longer the last key, what should happen?
On Fri, Jun 1, 2018 at 4:56 PM Gregory Ewing
wrote:
> Chris Angelico wrote:
> > It is an error to mutate the dictionary *and then continue to iterate
> over it*.
>
> But if you're processing the last key, and you add one so
> that it's no longer the last key, what should happen?
>
> My feeling is
On Fri, Jun 1, 2018 at 5:54 PM, Gregory Ewing
wrote:
> Chris Angelico wrote:
>>
>> It is an error to mutate the dictionary *and then continue to iterate over
>> it*.
>
>
> But if you're processing the last key, and you add one so
> that it's no longer the last key, what should happen?
>
> My feeli
Chris Angelico wrote:
It is an error to mutate the dictionary *and then continue to iterate over it*.
But if you're processing the last key, and you add one so
that it's no longer the last key, what should happen?
My feeling is that this should be an error, because it's
not clear whether itera
On Fri, Jun 1, 2018 at 12:37 AM, Frank Millman wrote:
> "Steven D'Aprano" wrote in message news:peorib$1f4$2...@blaine.gmane.org...
>>
>>
>> On Thu, 31 May 2018 10:05:43 +0200, Frank Millman wrote:
>>
>> > From the interpreter session below, you will see that adding a key while
>> > processing th
"Steven D'Aprano" wrote in message news:peorib$1f4$2...@blaine.gmane.org...
On Thu, 31 May 2018 10:05:43 +0200, Frank Millman wrote:
> From the interpreter session below, you will see that adding a key while
> processing the *last* key in an OrderedDict does not give rise to an
> exception.
I
On Thu, 31 May 2018 10:05:43 +0200, Frank Millman wrote:
> "Frank Millman" wrote in message news:pemchs$r12$1...@blaine.gmane.org...
>>
>> So working backwards, I have solved the first problem. I am no nearer
>> to
> figuring out why it fails intermittently in my live program. The message
> from
"Frank Millman" wrote in message news:pemchs$r12$1...@blaine.gmane.org...
So working backwards, I have solved the first problem. I am no nearer to
figuring out why it fails intermittently in my live program. The message
from INADA Naoki suggests that it could be inherent in CPython, but I am n
>
> So working backwards, I have solved the first problem. I am no nearer to
> figuring out why it fails intermittently in my live program. The message
> from INADA Naoki suggests that it could be inherent in CPython, but I am
not
> ready to accept that as an answer yet. I will keep plugging away a
"Steven D'Aprano" wrote in message news:pem8b8$lm6$4...@blaine.gmane.org...
On Wed, 30 May 2018 10:48:06 +0200, Frank Millman wrote:
> I tried to reduce it to a simple example. I succeeded, but there are two
> problems -
>
> 1. It always fails, so I have not reproduced the intermittent nature
On Wed, 30 May 2018 10:48:06 +0200, Frank Millman wrote:
> I tried to reduce it to a simple example. I succeeded, but there are two
> problems -
>
> 1. It always fails, so I have not reproduced the intermittent nature
> yet.
>
> 2. It gives a different error -
>
> RuntimeError: dictionary c
On Wed, 30 May 2018 23:05:53 +1000, Chris Angelico wrote:
> You can always change the *values*, but not the *order* of the keys.
Okay, so far we have these operations which are allowed:
- changing a value associated with a key
and these operations which all raise RuntimeError with the "mutated"
> However, the error seems to be intermittent - there are times when it
should
> fail, but does not - so I want to investigate further.
CPython raise RuntimeError *by chance*.
Detecting all invalid usage will increase runtime cost.
So CPython may and may not raise RuntimeError.
> I tried to redu
On Wed, May 30, 2018 at 10:55 PM, Steven D'Aprano
wrote:
> On Wed, 30 May 2018 05:03:02 -0400, Terry Reedy wrote:
>
>> On 5/30/2018 4:48 AM, Frank Millman wrote:
>>> Hi all
>>>
>>> I want to work backwards to solve this problem, so I have to explain it
>>> forwards to put you in the picture.
>>>
>
On Wed, 30 May 2018 10:48:06 +0200, Frank Millman wrote:
> So my first question is, what is the difference between the two error
> messages? I am using an OrderedDict for my test as well, so the
> difference is not caused by using a normal dictionary.
>From Object/orderdict.c I find:
/* Chec
On Wed, 30 May 2018 05:03:02 -0400, Terry Reedy wrote:
> On 5/30/2018 4:48 AM, Frank Millman wrote:
>> Hi all
>>
>> I want to work backwards to solve this problem, so I have to explain it
>> forwards to put you in the picture.
>>
>> I have an Ordered Dictionary. Under certain circumstances I am
On 5/30/2018 4:48 AM, Frank Millman wrote:
Hi all
I want to work backwards to solve this problem, so I have to explain it
forwards to put you in the picture.
I have an Ordered Dictionary. Under certain circumstances I am getting
this error -
RuntimeError: OrderedDict mutated during ite
Hi all
I want to work backwards to solve this problem, so I have to explain it
forwards to put you in the picture.
I have an Ordered Dictionary. Under certain circumstances I am getting this
error -
RuntimeError: OrderedDict mutated during iteration
I can see why this is happening, and
21 matches
Mail list logo