Naive Question
jim kraai
jkraai at murl.com
Sat Dec 4 13:25:37 EST 1999
Michael Hudson wrote:
>
> jim kraai <jkraai at murl.com> writes:
>
> > Greetings,
> >
> > If I have:
> >
> > class contrived_collection:
> > def __init__(self):
> > self.item = [{1,2},{3,4},{5,6}]
> >
> > a = contrived_collection()
> > b = a.item[2]
> >
> > How can I ask b what it is a member of?
>
> You can't, at least not without basically adding the information
> yourself. Watch out for cycles!
That's what I was afraid of.
> > I need to somehow know later in processing that:
> > 1. b is a member of a.item
> > 2. a.item is a member of a
>
> Hmm... what are you trying to do? Have you looked at Acquisition:
I want to make a recursive directory'ish listing and have a list
of indexes into it.
Now, I believe that I'll do it backwards. Have a linear list of
directory objects, and have a nested list of refs to them. Doesn't
solve the problem in the way that I wanted to do it, but thats OK!
Thanks!
> http://www.zope.org/Members/Amos/WhatIsAcquisition
>
> (which is zope biased; there may be another more generic intro
> somewhere but I can't find it just now).
>
> It s a very cute method for dealing with some problems a bit like
> this.
Hm, I've been able to avoid the Alternate Zope Universe to date.
Thanks for the answer to the question!
--jim
More information about the Python-list
mailing list