On Fri, Jan 25, 2013 at 4:57 PM, anthonym <antho...@att.net> wrote: > I have the code below that I used to create a simple tic tac toe game for > class. I am learning Python but have programmed in C+ before so I brought > over a lambda and found that it worked in Python. Unfortunately I don't > think my classmates will understand the use of lambda here but I am having > are hard time converting that to strictly python.
The code is expressing the idea of referring to a function, not to call it immediately, but rather to pass it as a value for someone else to call. This is something that's expressible in C++ too. http://en.wikipedia.org/wiki/C%2B%2B11#Lambda_functions_and_expressions But you probably won't see this in beginner-level code. Dealing with functions as values is important to learn, though, if you want to build an intermediate mastery of programming. The concept is a key component to things like event-driven programming, where you tell some other system what to do when certain things happen. That "what to do" is usually expressed by passing the thing a function value. In traditional C++, the kind of C++ you'd see several years ago, you can do the same sort of thing by passing around objects that have a virtual method. In that way, you can have a "function-like" value that can be passed and called. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor