"Alex Martelli" <aleaxit at yahoo.com> wrote in message news:9c45qg01sui at news1.newsguy.com... > "Rainer Deyke" <root at rainerdeyke.com> wrote in message > > 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 > > They are three ways to bind (or re-bind) names, but only two of them > ARE "assignments" -- Python's syntax defines assignments, plain and > augmented, rather precisely, and there is no 'def' keyword there:-). I count four ways ('import', 'def', '=', and augmented assignment), not counting 'globals().set' and similar tricks. > > 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. > > And you think newbies will find the definition for b any clearer?! No, because the keyword 'lambda' has no intrinsic meaning. Lambda syntax in its current form is problematic, but that doens't mean the idea behind it is. Some obvious readability improvements: 1. Change the keyword. b = lambda: None --> b = function: None 2. Place parenthesis around the argument list. b = function: None --> b = function(): None Of course unnamed functions will remain crippled as long as their body is limited to a single expression, and embedding a statement suite in an expression in Python is problematic because of indentation issues. -- 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