python - Using namedtuples to consolidate multiple dictionaries -


Given the number of models in which the key is m-number: add value, consolidate that information to named names Can one object be used to? By integrating, I mean refactor, so that I can cross this object and reach a special piece of information about it.

How it is organized at present:

 
  & gt; )   

Model_1_Dict ["variable name"] [1] code is updated later on I either start = any , and then could update the value on the calculation. Or later attach the value of the value list object (I think this is a non-issue).

I want to know whether the model structure is a better way to use other structures such as designated thongs?

Yes, you can use named designs - to the point where you said that you If you want to update the information within either the TUPS and the designated steps are not modified, therefore, if you want to give your data a name rate rate based on the index number, then you should either use the nested dictionary structure - or your own Creating a simple class to keep data Hia.

The benefit of creating a custom square is for the sake of that you restrict the properties with a __ slot __ attribute on the square, and you can customize it __ repr __ , so that it looks good on inspection -

with something:

  class data (object): __slots__ = (" Beta "," calculation "," function ") def __init __ (self, beta = none, calculation = none, function = none): self.beta = beta; Self.calculated = calculation; Self. Function = function def __repr __ (self): return "(% s,% s,% s)"% (self.beta, self.calculated, self.function)   

Which Works like this:

  & gt; & Gt; & Gt; Model_1_Dict = {'key1': data ('value1', 'value2', 'value3')}> gt; & Gt; & Gt; & Gt; & Gt; & Gt; Model_1_Dict {'key1': (value1, value2, value3)} & gt; & Gt; & Gt; Model_1_Dict ["key1"]. Beta = "new vele" and gt; & Gt; & Gt; Model_1_Dict {'key1': (NewValue, value2, value3)} & gt; & Gt; & Gt;    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -