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 6898329
In Process

The Archive Base Latest Questions

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

I found this very weird bug that I can’t understand. First of all inside

  • 0

I found this very weird bug that I can’t understand.

First of all inside this function I unpickle:

tableOrders = pickle.load(open("\\\\VIERNES7-3\Documentos c\sharedTableOrders.p","rb"))

If I do pprint(tableOrders) I get:

{1: {'blink': False,
     'canceled': 'no',
     'orders': [{u'availability': u'si',
                 u'canceled': u'no',
                 u'category': u'Minutas',
                 u'kitchen': u'si',
                 u'name': u'Hamburguesa al Plato',
                 u'parilla': u'no',
                 u'price': 60,
                 u'ready': u'no'},
                {u'availability': u'si',
                 u'canceled': u'no',
                 u'category': u'Minutas',
                 u'kitchen': u'si',
                 u'name': u'Hamburguesa al Plato',
                 u'parilla': u'no',
                 u'price': 60,
                 u'ready': u'no'}]}}

Now I iterate thought table orders in this manner:

count = 0
for x in tableOrders[table]["orders"]:
    if (x["kitchen"] == "si" or x["category"] == "Bebidas") and x["ready"] == "no":
        print count 
        print int(event.widget.curselection()[0]) 
        if count == int(event.widget.curselection()[0]):
                x["ready"] = "si"
                event.widget.delete(int(event.widget.curselection()[0]))
                break
        count += 1

int(event.widget.curselection()[0]) Will be the selected element of a listbox (it seems to work correctly).

The weird thing is that after I do this I have:

{1: {'blink': False,
     'canceled': 'no',
     'orders': [{u'availability': u'si',
                 u'canceled': u'no',
                 u'category': u'Minutas',
                 u'kitchen': u'si',
                 u'name': u'Hamburguesa al Plato',
                 u'parilla': u'no',
                 u'price': 60,
                 u'ready': u'si'},       <-------------- MARKED AS "si"
                {u'availability': u'si',
                 u'canceled': u'no',
                 u'category': u'Minutas',
                 u'kitchen': u'si',
                 u'name': u'Hamburguesa al Plato',
                 u'parilla': u'no',
                 u'price': 60,
                 u'ready': u'si'}]}}      <-------------- MARKED AS "si"

So both “ready” are marked as “si”, and that is not what I was expecting since I had put a break there and it should only change the property “ready” if the count == the selected element.

I tried also clicking the third element of the listbox (that has an index of 2) and this is what I got from print count and print int(event.widget.curselection()[0]):

0
2
1
2
2
2

This is why I am confused since only when both are equal (2 == 2) the x["ready"] = "si" code should be executed.

I’m not sure where the problem is, I’m quite lost but maybe I understanding the looping or break incorrectly or I’m confusing how to handle the dictionary and x["ready"] = "si" does something other that what I was expecting it to do.

Just in case it wasn’t clear, if I click the first element of the listbox (and thus int(event.widget.curselection()[0]) is zero) I want the first element of the list to be x[“ready”] == “si”, if I click on the second one the second element of the list should have the value “ready” to “si” and so on.

I did not tag this question with gui because I have discarded the possibility that the problem is there to the best of my knowledge.


EDIT:

Since the problem seems to be when I’m using the pickle here is more relevant code:

l = []
for item in sorted(jMenu["menu"]["items"]):
        if item["category"] == selectedCategory:
            l.append(item)
pedido = l[int(widget.curselection()[0])]

##pedido is something like this:
##pedido = {u'category': u'Bebidas', u'price': 40, u'name': u'Coca Cola', u'availability': u'si'}

Then I do:

tableOrders.addFood(activeTable, pedido)

addFood is

def addFood(self, table, food):
    if not table in self.tableList.keys():
        self.tableList[table] = {"orders":[food], "blink": False, "canceled": "no"}#el canceled hay que sacarlo?
    else:
        self.tableList[table]["orders"].append(food)

And to pickle I do:

def dumpTableOrders(self):
        tableOrders = pickle.load(open("sharedTableOrders.p","rb"))
        #pprint(self.tableList)

        for food in sorted(self.tableList[activeTable]["orders"]):
            if not activeTable in tableOrders.keys():
                tableOrders[activeTable] = {"orders":[food], "blink": False, "canceled": "no"}#el canceled hay que sacarlo?
            else:
                tableOrders[activeTable]["orders"].append(food)

        self.tableList = {}
        #pprint(tableOrders)
        pickle.dump(tableOrders, open(r'sharedTableOrders.p',"wb"))
  • 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-27T07:16:57+00:00Added an answer on May 27, 2026 at 7:16 am

    Problem is in the object you are pickling, surely there both objects are same e.g.

    >>> import pickle
    >>> d = {'name':'same'}
    >>> ds = pickle.dumps([d,d])
    >>> newd = pickle.loads(ds)
    >>> newd[0]['name'] = 'different'
    >>> newd
    [{'name': 'different'}, {'name': 'different'}]
    

    So look into the object you are picking and create copies there, alternative is to json dump it , that way you will not get same object again e.g.

    >>> import json
    >>> ds = json.dumps([d,d])
    >>> newd = json.loads(ds)
    >>> newd[0]['name'] = 'different'
    >>> newd
    [{u'name': 'different'}, {u'name': u'same'}]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found it very weird that simple code like this is not valid: select
I tracked down a very weird ... bug... I found that for some reason,
I found this question that was very useful in learning the basics of the
EDIT 9-3-10: I found this blog entry recently that was very enlightening. http://optimizermagic.blogspot.com/2007/12/outerjoins-in-oracle.html There
I know that this is a repeated question. I have found very similar questions
I found a weird bug in Rails 3.0.? that I want to report to
I found this problem, which is very weird. - (void)imageMove:(float)xx y:(NSInteger)yy { NSLog(@xx=%f,----yy=%d,xx,yy); }
I found this web site (photoblog) http://www.OneReaction.net/ and I am very curious how this
I have always found this to be a very useful feature in Visual Studio.
Very much related to my previous question , but I found this to be

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.