I believe that anything that can not be expressed as a Python anonymous function must be a def. It is possible to express conditionals and loops within a lambda statement, if that is what you are looking for:
hidden = [ file for file in os.listdir(givenpath) if file.startswith(".")] \ ..: if isdir(givenpath) \ ..: else [givenpath.startswith(".")
BTW, if a multi-statement anonymous function syntax was to be considered seriously, I'd recommend a lambda statement with colon replaced with a brace-delimited block, which would barely cause code written for an interpreter lacking it get refused: server = nodeishServer( lambda req, res { res.writeHead(200, ContentType= "text/html"); res.end("Hello"); } ) In fact, grammar for every statement which introduces a new block (if, def, for, with, lambda) can be altered such that if the statement ends with a `:' (semicolon), following lines are parsed as in usual Python syntax, or, if the statement ends with a `{' (left brace), following lines are parsed with non-indentation defined, C-ish syntax. So: def fibonacci(n): x, y, z = 1, 1, 0 for i in range(1, n): z = x x += y y = x return x could be also written as def fibonacci(n) { x, y, z = 1, 1, 0; for i in range(1, n) { z = x; x += y; y = x; } return x; } which is a) subject of a different thread, and b) ridiculous. -gk On 30 July 2013 18:19, Musical Notation <musicdenotation@gmail.com> wrote:
Yes, I know that multiline lambda will never be implemented in Python, but in many languages it is possible to write an anonymous function without using lambda at all. In JavaScript: Instead of "function <name>(<variables>){code}" you can write "var name; name=function(<variables>){code}" Python (proposed): def func(a,b): print(a+b) return a+b
becomes
func=function a,b: print(a+b) return a+b
_______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas