How to store the reference of a dictionary element ?
Alfredo P. Ricafort
alpot at mylinuxsite.com
Mon Dec 16 23:53:26 EST 2002
Not quite, but I can live with it if there are no more simple solution.
I am really planning to implement the 'values' as list. They are
actually attributes of a record. But my problem with this code is if I
mistakenly do this:
a['2']=[22]
instead of
a['2'][0]=22
then the link would be broken and I would end up with an orphan child in
my linked list. Currently, the number of attributes are not that many so
I can still afford to subscript each element during assignment.
> Try this:
>
> >>> a = {'1':[1], '2':[2]}
> >>>
> >>> b = {}
> >>> b['2']=a['2']
> >>> a['2'][0]= 22
> >>> b
> {'2': [22]}
>
> can that do what you need?
>
> Cheers,
> Terry
>
> --
> Terry Hancock ( hancock at anansispaceworks.com )
> Anansi Spaceworks http://www.anansispaceworks.com
>
> "Some things are too important to be taken seriously"
More information about the Python-list
mailing list