python - Easy building a dictionnary of dictionnaries or dictionnaries of -


Along with Python 3, I have to make the details of departures of listings ....

I'm wondering if there is a better way to do the code below (this looks like a garbage code ...)

  ret = {} list PhosphiensiensiariesFromongdatabase for r: a = TheObjectIUse (R) sp = a.getSp () ex = a.getEx () th = a.getTh () lo = a.getLo () de = a.getDe () If not [SP] [EX] = {} if not [SP] [EX]: ret [SP] [EX] [and] = {} if not earlier [SP]: [SP] = [} if: Not ret [es] [east] [th]: write [es] [x] [th] [lo] = [] write [es] [x] [and] [lo]. Append (d)   

Thank you for your help.

It is not a good practice to create complex data structures. I suggest that just use a simple dictionary with keys that is a tupal, so every key is a tube of multiple keys and each element can only be accessed using the appropriate key key.

  ret = {} list for r in the fdi ration of the Region databases: a = theObjectIUse (r) sp = A.getSp () ex = a.getEx () th = a.getTh () lo = a .getLo () de = a.getDe () tuple_key = (sp, ex, th, lo) if tuple_key is not in ret: ret [tuple_key] = [] ret [tuple_key] .append (d)  < / Pre>  

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -