<div class="gmail_quote">On 25 February 2011 15:49, <span dir="ltr"><<a href="mailto:info@gno.de">info@gno.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
>>> append = True<br>
<div class="im">>>> (lambda x: x and 'a' or 'w')(append)<br>
</div>'a'<br>
>>> append = False<br>
<div class="im">>>> (lambda x: x and 'a' or 'w')(append)<br>
</div>'w'<br></blockquote><div><br></div><div>By the way, alternative options would be:</div><div><br></div><div>>>> append = True</div><div>>>> append and 'a' or 'w'</div><div>'a'</div>
<div>>>> append = False</div><div>>>> append and 'a' or 'w'</div><div>'w'</div><div><br></div><div>Of course, the</div><div>>>> 'a' if append else 'w'</div>
<div><br></div><div>is nicer, but has only been supported for python 2.5+.</div><div><br></div><div>An alternative, third, method, would be</div><div><br></div><div>>>> append = True</div><div>>>> ['w', 'a'][append]</div>
<div>'a'</div><div>>>> append = False</div><div>>>> ['w', 'a'][append]</div><div>'w'</div><div><br></div><div>No reason to change the working code, of course, but just possibilies to keep in mind.</div>
<div><br></div><div>Best regards,</div><div>Merlijn</div><div><br></div></div>