[Tutor] sorted question
It't me
linux4n6 at gmail.com
Tue Jan 25 20:46:12 CET 2011
Hi all,
I'm learning Python with Google's Python class
Ik have a question about the following code:
=================================
def sort(var):
return var[-1] #returns the last character of var
def sort_last():
tup = [(1, 3), (3, 2), (2, 1)]
print(sorted(tup, key=sort))
sort_last()
==================================
I uderstand everything except (var) value.
I understand that key=sort calls the sort function.
But where comes the var value from?
Does sort automatic pass the value from tup to (var)
because (var) is nowhere defined.
Thanks,
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110125/9dce4c8a/attachment.html>
More information about the Tutor
mailing list