<div dir="ltr">Maybe it's just the C++ IO piping that makes me like it, but these actually seem intuitive to me, whereas `+` or even `|` leaves me queasy.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 9, 2019 at 7:40 PM Ian Foote <<a href="mailto:ian@feete.org">ian@feete.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail-m_-2175699857925669563gmail-gE gmail-m_-2175699857925669563gmail-iv gmail-m_-2175699857925669563gmail-gt"><table class="gmail-m_-2175699857925669563gmail-cf gmail-m_-2175699857925669563gmail-gJ" cellpadding="0"><tbody><tr class="gmail-m_-2175699857925669563gmail-acZ gmail-m_-2175699857925669563gmail-xD"><td colspan="3">> It might also be worth considering YAML's own dict merge operator, the<br>
> "<<" operator, as in <a href="https://yaml.org/type/merge.html" rel="noreferrer" target="_blank">https://yaml.org/type/merge.html</a> as this is the<br>
> existing Python's shift operator added to dict and will require no<br>> change to the synatx::<br>
><br>> a = a << b<table class="gmail-m_-2175699857925669563gmail-cf gmail-m_-2175699857925669563gmail-adz" cellpadding="0"><tbody><tr><td class="gmail-m_-2175699857925669563gmail-ady"><div><img class="gmail-m_-2175699857925669563gmail-ajz" id="gmail-m_-2175699857925669563gmail-:6gd" src="https://mail.google.com/mail/u/0/images/cleardot.gif" alt=""><br>I
really like this suggestion. It captures the asymmetry, since we could
have a = a >> b to merge with the other dictionary's keys taking
precedence.<br><br></div></td></tr></tbody></table></td></tr></tbody></table></div><div class="gmail-m_-2175699857925669563gmail-"><div id="gmail-m_-2175699857925669563gmail-:31j" class="gmail-m_-2175699857925669563gmail-ii gmail-m_-2175699857925669563gmail-gt gmail-m_-2175699857925669563gmail-adO"><div id="gmail-m_-2175699857925669563gmail-:2v4" class="gmail-m_-2175699857925669563gmail-a3s gmail-m_-2175699857925669563gmail-aXjCH"><div dir="ltr"><div>My instinct is that a = a << b would
take b's values when keys collide and a = a >> b would take a's
values when keys collide. I'd be very interested to know if this matches
most peoples' intuitions.</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 9 Mar 2019 at 18:44, Meitham Jamaa <<a href="mailto:m@meitham.com" target="_blank">m@meitham.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It might also be worth considering YAML's own dict merge operator, the<br>
"<<" operator, as in <a href="https://yaml.org/type/merge.html" rel="noreferrer" target="_blank">https://yaml.org/type/merge.html</a> as this is the<br>
existing Python's shift operator added to dict and will require no<br>
change to the synatx::<br>
<br>
a = a << b<br>
<br>
Meitham<br>
<br>
<br>
On 03/10, Chris Angelico wrote:<br>
> On Sun, Mar 10, 2019 at 3:16 AM Jonathan Fine <<a href="mailto:jfine2358@gmail.com" target="_blank">jfine2358@gmail.com</a>> wrote:<br>
> ><br>
> > Anders Hovmöller wrote:<br>
> ><br>
> > > I don't understand what you mean. Can you provide examples that show the state of the dicts before and after and what the syntax would be the equivalent of in current python?<br>
> ><br>
> > If a.__radd__ exists, then<br>
> > a += b<br>
> > is equivalent to<br>
> > a = a.__radd__(b)<br>
> ><br>
> > Similarly, if a.__iat_update__ exists then<br>
> > a @update= b<br>
> > would be equivalent to<br>
> > a = a.__iat_update__(b)<br>
> ><br>
> > Here's an implementation<br>
> > def __iat_update__(self, other):<br>
> > self.update(other)<br>
> > return self<br>
> ><br>
> > Thus, 'b' would be unchanged, and 'a' would be the same dictionary as<br>
> > before, but updated with 'b'.<br>
> <br>
> With something this long, how is it better from just writing:<br>
> <br>
> a = a.update_with(b)<br>
> <br>
> ? What's the point of an operator, especially if - by your own<br>
> statement - it will backward-incompatibly change the language grammar<br>
> (in ways that I've yet to understand, since you haven't really been<br>
> clear on that)?<br>
> <br>
> ChrisA<br>
> <br>
<br>
-- <br>
Meitham Jamaa<br>
<br>
<a href="http://meitham.com" rel="noreferrer" target="_blank">http://meitham.com</a><br>
GPG Fingerprint: 3934D0B2<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>