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

For example:

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

is readable - barely.

result = map(def (x, y, z):
something else
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 else
return x

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

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


Follow ups

Related Discussions

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



site design / logo © 2023 Grokbase