As an aside only, it would be pretty reasonable IMO to have<br><br>name = value if condition<br><br>and set name to None otherwise<br><br>But I'm -1 on the idea as I think it's a bit redundant.<br><br>Cheers,<br>-T<br>
<br><div class="gmail_quote">On Wed, Apr 8, 2009 at 12:55 AM, spir <span dir="ltr"><<a href="mailto:denis.spir@free.fr">denis.spir@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Le Tue, 7 Apr 2009 23:38:21 +1000,<br>
Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> s'exprima ainsi:<br>
<div class="im"><br>
> > What's the reason why<br>
> > name = value if condition<br>
> > is invalid? Meaning: there _must_ be an else clause.<br>
<br>
> Because "value if condition else other" is an expression, not a<br>
> statement, and thus *must* have a value.<br>
><br>
> name = value if condition<br>
><br>
</div>> only has a value sometimes, and so is invalid [...]<br>
<br>
Yes, thank you! That's the explaination I was looking for.<br>
I meant to use the above formulation for updating already defined variables. Indeed, python does not make the difference I have in mind ;-).<br>
<br>
As a side note,<br>
if condition: name = value<br>
(where 'name' is already registered) is the only case when I do not indent a block, for the reason that it means for me the same as the above invalid one-liner.<br>
<br>
Denis<br>
------<br>
la vita e estrany<br>
<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>--------------------------------------------------<br>Tennessee Leeuwenburg<br><a href="http://myownhat.blogspot.com/">http://myownhat.blogspot.com/</a><br>"Don't believe everything you think"<br>