[PEAK] trellis attrs

nicky van foreest vanforeest at gmail.com
Fri Sep 30 14:46:22 EDT 2011


On 30 September 2011 18:57, PJ Eby <pje at telecommunity.com> wrote:
> On Fri, Sep 30, 2011 at 8:05 AM, nicky van foreest <vanforeest at gmail.com>
> 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


More information about the PEAK mailing list