Hi all.
In my application I have chosen as data structure a list of
dictionaries. Each dictionary has just one key and the corresponding
value.
structure = [{'field1': lenght1}, {'field2': lenght2}, ]
Initially, to obtain the key and the value I used this code,
for structure in record_st
Negroup - said unto the world upon 2005-11-21 03:26:
> Hi all.
> In my application I have chosen as data structure a list of
> dictionaries. Each dictionary has just one key and the corresponding
> value.
>
> structure = [{'field1': lenght1}, {'field2': lenght2}, ]
>
> Initially, to obtai
Hi,
mydic = {'one': 1, 'two': 2} # to access key: for x in mydic.keys(): print x # to access value --> use key print mydic['one']
Cheers,
pujo
On 11/21/05, Negroup - <[EMAIL PROTECTED]> wrote:
Hi all.In my application I have chosen as data structure a list ofd
> Each dictionary has just one key and the corresponding
> value.
>
> structure = [{'field1': lenght1}, {'field2': lenght2}, ]
I'd use a tuple rather than a dictionary here:
structure = [('field1', lenght1), ('field2', lenght2), ]
> but after some thoughts I arrived to:
> field_n
2005/11/21, Brian van den Broek <[EMAIL PROTECTED]>:
> Hi Negroup,
>
> why not just make structure a dict:
>
> structure = {'field1': lenght1, 'field2': lenght2}
>
> What does having a list of dicts all with a single key add but a layer
> of referencing when you want to access?
>
> If you are tryi
2005/11/21, Alan Gauld <[EMAIL PROTECTED]>:
> > Each dictionary has just one key and the corresponding
> > value.
> >
> > structure = [{'field1': lenght1}, {'field2': lenght2}, ]
>
> I'd use a tuple rather than a dictionary here:
Of course, this makes a lot of sense.
[cut]
> you can now
> Probably due to the lacking of experience, but each time I code a
> datastructure I am never satisfied, and I have the feeling that I'm
> not on the right way..
The same thing happens to me. I actually have a very similar problem to
yours now, and I'm rather considering a list of two-element t