Showing content from http://mail.python.org/pipermail/python-dev/attachments/20140224/3367a447/attachment.html below:
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 22/02/2014 21:26, Tim Delaney wrote:<br>
</div>
<blockquote
cite="mid:CAN8CLg=vzhmLB6SfozkL-by6spaVgdHxux6A8TqSm_+EkVC_QA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra"><br>
<div class="gmail_quote">On 23 February 2014 02:29, Nick
Coghlan <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="">
<p dir="ltr">On 22 Feb 2014 22:15, "Stephen J. Turnbull"
<<a moz-do-not-send="true"
href="mailto:stephen@xemacs.org" target="_blank">stephen@xemacs.org</a>>
wrote:<br>
> Antoine Pitrou writes:<br>
> Â > Chris Angelico <<a
moz-do-not-send="true"
href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>>
wrote:<br>
> Â > > hasattr(x,"y") <-> (x.y or True
except AttributeError: False)<br>
> Â > But it's not the same. hasattr() returns a
boolean, not an arbitrary<br>
> Â > value.<br>
> I think he meant<br>
> Â Â hasattr(x,"y") <-> (x.y and True except
AttributeError: False)</p>
</div>
<p dir="ltr">With PEP 463, the explicit equivalent of
hasattr() would be something like :</p>
<p dir="ltr">hasattr(x,"y") <-> (bool(x.y) or True
except AttributeError: False)</p>
</blockquote>
<div>That would work, but I think I'd prefer:</div>
<div><br>
</div>
<div>hasattr(x,"y") <-> bool(x.y or True except
AttributeError: False)<br>
</div>
<div><br>
</div>
<div>Makes it clearer IMO that the entire expression will
always return a boolean.</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
This also works:<br>
<br>
hasattr(x,"y")Â <->Â (lambda v: True)(x.y) except
AttributeError: False   <br>
<br>
Which is less obscure is a matter of judgement.<br>
</body>
</html>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4