<br><br><div class="gmail_quote">2009/10/19 Oleg Broytman <span dir="ltr"><<a href="mailto:phd@phd.pp.ru">phd@phd.pp.ru</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Mon, Oct 19, 2009 at 10:28:58PM +0800, starwing wrote:<br>
> Oleg Broytman ??????:<br>
<div class="im">>>    Single-line lambdas are good enough,<br>
>> and if you need more - just create a named function.<br>
>><br>
</div><div class="im">> BUT, why we need a name? just to process something or make decide,<br>
> sometimes code itself is enough.<br>
<br>
</div>   A multiline function is certainly not a simple piece of code; it<br>
requires documentation - docstring, comments - and the name is a part of<br>
the documentation.<br>
<div class="im"><br></div></blockquote><div><br><br>Having used languages that allow multiline anonymous functions (C#, Javascript) I have to say that they *can* improve the readability of code. Being forced to define functions ahead of where they belong in the logical flow of the program is not a feature of Python but a restriction.<br>
<br>To dogmatically assert that multiline anonymous functions are *necessarily* less clear simply does the reputation of Python damage to those who use them already in other languages and know that this isn't true. <br>
<br>I accept that it is a necessary restriction in Python (basically impossible to find a clean syntax that fits in with indentation for block structure) but to pretend that it is anything other than a restriction insults the intelligence of your audience.<br>
<br>Michael<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
> and, is there performance problems when you define a inner function in<br>
> another function? (that's, that function will define every time you call<br>
> the function or not?)<br>
<br>
</div>   A lambda, like an inner function, is recreated every time, so it's<br>
certainly no better than a named function.<br>
   You should profile your program to prove there is really a performance<br>
degradation. And if there is - create a global function instead.<br>
<div class="im"><br>
Oleg.<br>
--<br>
     Oleg Broytman            <a href="http://phd.pp.ru/" target="_blank">http://phd.pp.ru/</a>            <a href="mailto:phd@phd.pp.ru">phd@phd.pp.ru</a><br>
           Programmers don't die, they just GOSUB without RETURN.<br>
_______________________________________________<br>
</div><div><div></div><div class="h5">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.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a><br><br><br>