define function in function
Thomas Thiele
thiele at muc.das-werk.de
Wed Aug 2 15:38:20 EDT 2000
I have a problem witing a sort function within a memberfunction.
class X:
.......
def function(self, dictionary):
list = []
...set list entries...
def sortf(lx, ly):
return cmp( dictionary[lx], dictionary[ly] )
list.sort(sortf)
The dict includes some integer numbers as values. The list shall be
sortet by using this numbers.
How can I realize that dictionary is know in sortf ?
delaring dictionary as global in the function or saying d = dictionary,
and declaring d as global and using d, all don't work.
Can you help me? How is the trick?
More information about the Python-list
mailing list