Re: trellis attrs

nicky van foreest <[email protected]> Fri, 30 Sep 2011 20:46:22 +0200
Newsgroups gmane.comp.python.peak
Message-ID <CAK_GA2EnfPZw1JcN13iCMN7Y+F_O5ZEw11KRgdtAd2+QfqP5bQ@mail.gmail.com>
On 30 September 2011 18:57, PJ Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> wrote:
> On Fri, Sep 30, 2011 at 8:05 AM, nicky van foreest <[email protected]>
> wrote:
>>
>> I tried the following, but this failed.
>>
>> class Batch(trellis.Component):
>>    trellis.attrs(
>>        prevs = trellis.Set([],
>>        duration = 0,
>>    )
>>  ...
>>  The problem is that all batches use the same trellis.Set, but I want
>> each batch to have its own trellis.Set. How can I achieve this?
>
> I'll go ahead and just answer this bit, because it's the part I can
> understand without more detailed study.  Hopefully it'll get you what you
> need.  ;-)
> Do this:
> class Batch(trellis.Component):
>      prevs = trellis.make(trellis.Set)
>      duration = trellis.attr(0)

I'll try this right now.

>
>
>>
>>  (I know that removing an item from a trellis.set is impossible.
>
> Uh, what?  Where'd you get that idea?

I simply misinterpreted the following documentation:

"Trellis Set objects offer nearly all the comforts of the Python
standard library's sets.Set objects (minus .pop(), and support for
sets of mutable sets), but with observability:""

Thanks for your tips.

Nicky