<div dir="ltr"><br><div class="gmail_quote"><br><div dir="ltr"><div>Ivan,<br><br></div>Did you mean this to go to the list? I hope so, as I've cc-d it this time :-)<br><div><div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Sun, Jul 1, 2018 at 1:20 AM, Ivan Levkivskyi <span dir="ltr"><<a href="mailto:levkivskyi@gmail.com" target="_blank">levkivskyi@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><span class="">On 1 July 2018 at 06:18, Chris Barker via Python-ideas <span dir="ltr"><<a href="mailto:python-ideas@python.org" target="_blank">python-ideas@python.org</a>></span> wrote:<br></span><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div class="gmail_extra"><div class="gmail_quote"><span></span>I'm really warming to the:<div><br></div>Alternate: <span style="font-family:monospace,monospace">collections.Grouping</span></div><div class="gmail_quote"><br></div><div class="gmail_quote">version -- I really like this as a kind of custom mapping, rather than "just a function" (or alternate constructor) -- </div></div></div></div></div></div></div></blockquote></span></span></div></div></div></blockquote><div><br></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span></span>I wanted the group to be represented as a set, not a list. I however understand that list may be more common. Can we design an API that<div>would make this configurable? Something like:</div><div><br></div><div>    from collections import Grouping</div><div><br></div><div>    deps = Grouping(set)  # list can be the default</div><div>    deps.update(other_deps)  # uses set.update or list.extend for every key</div><div>    deps.add(trigger, target)  # uses set.add or list.append</div></div></div></div></blockquote><div><br></div></span><div>yeah, I thought about that too -- Michael was using set() in some of his examples.<br><br></div><div>But the question is -- do we have a single switchable version or just too classes?<br> </div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Probably allowing an arbitrary collection for values is to general/hard. </div></div></div></div></blockquote><div><br></div></span><div>maybe not -- if we had the criteria that you pass in any collection you wanted, as long as it had either an <span style="font-family:monospace,monospace">.append()</span> or <span style="font-family:monospace,monospace">.add()</span>method, it would be pretty easy to do with duck typing magic.<span style="font-family:monospace,monospace"><br><br></span></div><div>Sure -- a user could make a mess easily enough by passing in a weird custom class, but so what? Using something other than a set or list would be a "at your own risk" thing anyway.<span style="font-family:monospace,monospace"></span><br> </div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Maybe we can just add a flag `unique=True` to the constructor, that will cause using sets instead of lists for groups?</div></div></div></div></blockquote><div><br></div></span><div>That's another, more robust, but less flexible option.<br><br></div><div>Stay tuned for a prototype, if I can get it done fast....<br><br></div><div>-CHB<br><br></div></div><span class=""><br>-- <br><div class="m_-3810725848726083201gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</span></div></div></div></div>
</div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div>