Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 968263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:27:02+00:00 2026-05-16T02:27:02+00:00

In the below code d_arr is an array of dictionaries def process_data(d_arr): flag2 =

  • 0

In the below code d_arr is an array of dictionaries

 def process_data(d_arr):
    flag2 = 0
    for dictionaries in d_arr:  
      for k in dictionaries:
        if ( k == "*TYPE" ):
          """ Here we determine the type """
          if (dictionaries[k].lower() == "name"):
            dictionaries.update({"type" : 0})
            func = name(dictionaries)
            continue
          elif (dictionaries[k].lower() == "ma"):
            dictionaries.update({"type" : 1})
            func = DCC(dictionaries)
            logging.debug(type(func))
           continue      

When the above is done i get an error saying

               for k in dictionaries:
            RuntimeError: dictionary changed size during iteration
           2010-08-02 05:26:44,167 DEBUG Returning

Is this forbidden to do something like this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:27:02+00:00Added an answer on May 16, 2026 at 2:27 am

    It is, indeed, forbidden. Moreover, you don’t really need a loop over all keys here, given that the weirdly named dictionaries appears to be a single dict; rather than the for k in dictionaries: (or the workable for k in dictionaries.keys() that @Triptych’s answer suggests), you could use…:

        tp = dictionaries.get('*TYPE')
        if tp is not None:
          """ Here we determine the type """
          if tp.lower() == 'name':
            dictionaries.update({"type" : 0})
            func = name(dictionaries)
          elif tp.lower() == "ma":
            dictionaries.update({"type" : 1})
            func = DCC(dictionaries)
            logging.debug(type(func))
    

    This is going to be much faster if dictionaries has any considerable length, for you’re reaching directly for the one entry you care about, rather than looping over all entries to check each of them for the purpose of seeing if it is the one you care about.

    Even if you’ve chosen to omit part of your code, so that after this start the loop on dictionaries is still needed, I think my suggestion is still preferable because it lets you get any alteration to dictionaries done and over with (assuming of course that you don’t keep altering it in the hypothetical part of your code I think you may have chosen to omit;-).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the below code to save data in array, arr[]['name'] = 'hello'; arr[]['value'] =
Look the code below. I'd like to replace USERNAME by the field name received
The below code is from my other questions that I have asked here on
Below code is dealing with a TYPE* const pointer. struct D { void Check
In the below code, I can display the first returned JSON place name result
I have the below code, $lastmonthLastDay = date('Y-m-d', strtotime(last day of last month)); $lastmonthFirstDay=
The code below works well right now; however, it's serially executed. I'd like to
I'd like to retrieve the image source within the below HTML code block, but
i have the following code below: const char* timeformat = %Y-%m-%d %H:%M:%S; const int
When I run the code below NSString *chemin; chemin = [NSString stringWithFormat:@chapitre0%d, [sender tag]];

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.