Now this is a concrete example of how lambda simplifies code, at
least
for me because it does not clutter my mental name space.  Also it is
much shorter.  However it should be said that this is very much a
question of taste.

Agreed. Which would make it pointless to remove in a future release. ;-)

However I must say that lambda's are very useful
even necessary for using Tkinter.

I'll bet that there is an easy enough way to use Tkinter without them
(Before anyone wants to argue my points, I would like to say that I'm neutral in
this discussion, I only wish to point out alternative views)


aFuncList=[]
def x():
   print "one"
aFuncList.append(x)
def x():
   print "two"
aFuncList.append(x)
def x():
   print "three"
aFuncList.append(x)
for item in aFuncList:
   item()

Okay, for this problem (it can be altered otherwise)

def makefunct(stri):
   def x():
       print stri
   return x
aFuncList = [makefunct('one'),makefunct('two'),makefunct('three')]
for item in aFuncList:
   item()

It's shorter, it works and it looks cool.
Thanks to Jeff Shannon for the backbone of this example.

Jacob Schmidt

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to