May-20-2018, 12:15 PM
(This post was last modified: May-20-2018, 12:15 PM by 3dimensions.)
I will try to explain what problem I have:
I have an attribute class dictionary called "diccpuntscontrol" which is annoying me because for some unknown reason it's not working properly.
Basically there is a problem when recovering the data of the whole class which previously has been saved on the dictionary "Dicc_Curses".
The recovering function "get_cursa" searches Dicc_Curses and let's you get the data of the race. All of the class variables except "diccpuntscontrol" show properly but for some unknown reason "diccpuntscontrol" is always {} when it shouldn't be.
If it helps also, I made a testing code to see whether the problems gets fixed somehow and surprisingly here works properly:
I have an attribute class dictionary called "diccpuntscontrol" which is annoying me because for some unknown reason it's not working properly.
Basically there is a problem when recovering the data of the whole class which previously has been saved on the dictionary "Dicc_Curses".
class Cursa: Dicc_Curses = {} def __init__ (self, nomcursa, nummaxparticipants, numpuntscontrol, estatcursa = "creada", diccpuntscontrol = None, diccparticipants = None): self.nomcursa = nomcursa self.nummaxparticipants = nummaxparticipants self.numpuntscontrol = numpuntscontrol self.estatcursa = estatcursa if diccpuntscontrol is None: self.diccpuntscontrol = {} else: self.diccpuntscontrol = diccpuntscontrol if diccparticipants is None: self.diccparticipants = {} else: self.diccparticipants = diccparticipants def guardar_cursa (nomcursa, cursa): Cursa.Dicc_Curses[nomcursa] = cursa def get_cursa (nomcursa): return Cursa.Dicc_Curses[nomcursa] def print (self): print (self.diccpuntscontrol) # How I save the race, of course this belongs to another part of the code, just copying here if it helps c = Cursa (nomcursa, nummaxcorredors, 2, "creada", ppc_dicc) # ppc_dicc is the dictionary that should become diccpuntscontrol and it is NOT empty Cursa.guardar_cursa (nomcursa, c) # How do I restore the data of the race, of course this belongs to another part of the code, just copying here if it helps c = Cursa.get_cursa (nomcursa) c.print() # c.print is here for testing purposes only
Output:{}
The saving function "guardar_cursa" saves the object "cursa" and the name of the race "nomcursa" in "Dicc_Curses".The recovering function "get_cursa" searches Dicc_Curses and let's you get the data of the race. All of the class variables except "diccpuntscontrol" show properly but for some unknown reason "diccpuntscontrol" is always {} when it shouldn't be.

If it helps also, I made a testing code to see whether the problems gets fixed somehow and surprisingly here works properly:
class Cursa: Dicc_Curses = {} def __init__ (self, nomcursa, diccpuntscontrol = None): self.nomcursa = nomcursa if diccpuntscontrol is None: self.diccpuntscontrol = {} else: self.diccpuntscontrol = diccpuntscontrol def guardar_cursa (nomcursa, cursa): Cursa.Dicc_Curses[nomcursa] = cursa def get_cursa (nomcursa): return Cursa.Dicc_Curses[nomcursa] def print (self): print (self.diccpuntscontrol) c = Cursa ("nomcursa", {'S': {}, 'A': {}}) c.print() Cursa.guardar_cursa ("nomcursa", c) d = Cursa.get_cursa ("nomcursa") d.print()
Output:{'S': {}, 'A': {}}
{'S': {}, 'A': {}}