<div dir="ltr">Actually, what I wanted was to be able to reference the variable being assigned to</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 11, 2013 at 7:07 PM, David Mertz <span dir="ltr"><<a href="mailto:mertz@gnosis.cx" target="_blank">mertz@gnosis.cx</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="im">On Thu, Jul 11, 2013 at 4:57 PM, Joao S. O. Bueno <span dir="ltr"><<a href="mailto:jsbueno@python.org.br" target="_blank">jsbueno@python.org.br</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't know if what I miss most is the samething the OP is asking for -<br>
but the idea of re-using a value retrieved in an expression in the<br>
same expression - without the need<br>
to assign to a temporary variable.<br>
<br>
Like in:<br>
value = expensive_function(b) if expensive_function(b) else default_value<br>
<br>
(of course this is a trivial example - but nonetheless it would require an<br>
extra "if" statement to avoid the double call)<br></blockquote><div><br></div></div><div>How about:<br><br></div><div> value = expensive_function(b) or default_value<br><br></div><div>One call, exact same behavior as you request. Available since Python 1.0.<span class="HOEnZb"><font color="#888888"><br>
</font></span></div><span class="HOEnZb"><font color="#888888"><div><br clear="all"></div></font></span></div><span class="HOEnZb"><font color="#888888"><br>-- <br>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>
</font></span></div></div>
<br>_______________________________________________<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Corey Sarsfield<br>
</div>