Name: Anonymous 2007-08-31 17:26 ID:FWVhjd5S
It's pretty neat. Thread over?
print turned out to be a mistake, but stuff like if and function definition should never need to be redefined or passed, and having them as statements makes the syntax a lot cleaner, and the code more readable.
lambda x, y, z: y if x or z looks like a function I might need to pass one day, but whether you can think of a case where you'd need to pass something or not is not valid justification for making a separate poor brother of expressions with a separate, incompatible syntax (one more thing to learn). Readability counts, but statements shouldn't be necessary to make the syntax clearer; the expression syntax should be clear already, and if it's not, we have a problem for which statements are a nigger rig of a solution that will only make things worse.def itself, which wouldn't make much sense in Python anyway, and alternatives like (disregarding the = statement):
f = function((x, y),
...
)if, def and lambda look?
x = 1 + 2 + if a:
#Begin the forced indentation of code
y = 0
for i in xrange(...):
#Nested forced indentation of code
y = ...
y #This makes the "if" evaluate to y
#Now we can go back to the first indentation level, closing the if.
#As you would expect, an if without else returns None if false.
#And we could even define an else:
else:
c #Return cx = t if c else f
x = if c:
t
else:
f
x = if c: t; else f
fa = lambda x: x + 1
def fb(x):
while something:
...
return x + whatever
def _temp(x):
...statements...
return x + whatever
higher_order_function(1, 2, _temp, 3, 4)
fa = def x: x + 1
#No need for parens
fb = def x:
while something:
...
x + whatever
#No need for _temp
higher_order_function(1, 2, def x:
...statements...
x + whatever
, 3, 4)