<div class="gmail_quote">On 25 July 2010 19:48, Raymond Hettinger <span dir="ltr"><<a href="mailto:raymond.hettinger@gmail.com">raymond.hettinger@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
On Jul 25, 2010, at 11:15 AM, Alex Gaynor wrote:<br>
<br>
> Recently I've been wondering why __contains__ casts all of it's<br>
> returns to be boolean values.  Specifically I'd like to propose that<br>
> __contains__'s return values be passed directly back as the result of<br>
> the `in` operation.<br>
<br>
</div>x = y in z          # where x is a non boolean.<br>
<br>
Yuck.<br>
<br></blockquote><div><br><br>How is it any worse than:<br><br><br> x = y > z # where x is a non boolean<br><br>And all the other operators that already do this?<br><br>Michael<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

One of the beautiful aspects of __contains__ is that its simply signature<br>
allows it to be used polymorphically throughout the whole language.<br>
It would be ashamed to throw-away this virtue so that you can<br>
have a operator version of something that should really be a method<br>
(like find() for example).<br>
<br>
-1 on the proposal because it makes the language harder to grok<br>
while conferring only a dubious benefit (replacing well named<br>
methods with a non-descriptive use of an operator).<br>
<br>
There is no "natural" interpretation of an in-operator returning<br>
a non-boolean.  If the above snippet assigns "foo" to x, what<br>
does that mean?  If it assigns -10, what does that mean?<br>
Language design is about associating meanings (semantics)<br>
with syntax.  ISTM, this would be poor design.<br>
<font color="#888888"><br>
<br>
Raymond<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.voidspace.org.uk">http://www.voidspace.org.uk</a><br><br><br>