nested structure with "internal references"

akonsu akonsu at
Fri Sep 25 20:02:40 CEST 2009

On Sep 25, 1:11 pm, Torsten Mohr <tm... at> wrote:
> Hi,
> sorry for posting in german before, that was a mistake.
> I'd like to use a nested structure in memory that consists
> of dict()s and list()s, list entries can be dict()s, other list()s,
> dict entries can be list()s or other dict()s.
> The lists and dicts can also contain int, float, string, ...
> But i'd also like to have something like a "reference" to another
> entry.
> I'd like to refer to another entry and not copy that entry, i need to
> know later that this is a reference to another entry, i need to find
> also access that entry then.
> Is something like this possible in Python?
> The references only need to refer to entries in this structure.
> The lists may change at runtime (entries removed / added), so
> storing the index may not help.
> Thanks for any hints,
> Torsten.


maybe i know less python than you do, but i am talking from the point
of view of my common sense and experience. if you store an object in a
list more than once, i doubt that python creates a duplicate. unless
the object is a value type. thus you have a reference to this object
in both elements. and then if you are asking this question, maybe your
design is not good enough? would you explain the problem?

More information about the Python-list mailing list