FAQ
In article <mailman.407.1080229887.742.python-list at python.org>,
Shane Hathaway wrote:
John Roth wrote:
If you can make a contribution to a good syntax for
a code block, I for one would welcome it.

Just to give you a start: Ruby puts a single code block
at the end of the parameter list where it's quite obvious
what it is and where it does not interrupt the flow of reading
the method call. In python, I'd like to be able to put code
blocks wherever I can currently put a function / method
object.

For example:

result = map(lambda: ..., list1, list2, list3)

is readable - barely.

result = map(def (x, y, z):
something
something else
return
list1, list2, list3)

becomes much less readable. This is the problem that
needs to be solved to make code blocks fly.
That's one of the things I'm trying to achieve, too. Using this syntax,
I would write it this way:

result = map(def(x, y, z), list1, list2, list3):
something
something else
return x

Shane
What do you do if the expression is in an "if" statement?


if map(def(x,y,z),list1,list2,list3):
# what goes here? The body of the function
# or the body of the if? And how does the rest of it
# look?



Also, limiting to "one per expression" prevents you from doing something
like:

myHandlers = {
"click" : def(x,y):
print "click at x,y"
"enter" : def():
print "mouse entered"
"exit" : def():
print "mouse exited"
}

(since you'd have to write:

myHandlers = {
"click" : def(x,y),
"enter" : somePreviousFunctionForEnter,
"exit" : somePreviousFunctionForExit
} :
print "click at x,y"

which, due to the large distance between the "def" and the body is
terribly hard to figure out)

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 23 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedMar 24, '04 at 9:58p
activeMar 27, '04 at 12:58a
posts23
users7
websitepython.org

People

Translate

site design / logo © 2022 Grokbase