Alex Martelli writes: > > > Unnamed blocks are a very powerful programming device. As far as I can > > But where's the extra power in making them UNNAMED? It's > so easy to name them, after all. Leaving things unnamed can make code a lot more readable (and writable). Consider: def f(a, b, c): return (-b + (b*b - 4*a*c) ** 0.5) / (2 * a) vs. def f(a, b, c): negative_b = -b b_squared = b*b four_a = 4 * a four_a_c = four_a * c b_squared_minus_four_a_c = b_squared - four_a_c radical_b_squared_minus_four_a_c = b_squared_minus_four_a_c ** 0.5 numerator = negative_b + radical_b_squared_minus_four_a_c demoninator = 2 * a result = numerator / demominator return result In Python, unnamed objects have an additional benefit: there is a single consistent way of naming them. Consider: a = 5 b = lambda: None def c(): pass These are three assignments, but only two look like assingments. The special syntax for the third case does not make it clear to newbies that 'c' is a reference like any other which happens to refer to a function object. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
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