nested structure with "internal references"

akonsu akonsu at gmail.com
Fri Sep 25 14:02:40 EDT 2009


On Sep 25, 1:11 pm, Torsten Mohr <tm... at s.netic.de> 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.

hello,

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?
konstantin



More information about the Python-list mailing list