Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4718bf8

Browse files
committed
Convert some custom sort comparison functions to equivalent key functions.
1 parent 53dbe39 commit 4718bf8

2 files changed

Lines changed: 2 additions & 15 deletions

File tree

Lib/idlelib/configDialog.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -980,16 +980,11 @@ def LoadThemeCfg(self):
980980
self.SetThemeType()
981981
##load theme element option menu
982982
themeNames = list(self.themeElements.keys())
983-
themeNames.sort(self.__ThemeNameIndexCompare)
983+
themeNames.sort(key=lambda x: self.themeElements[x][1])
984984
self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
985985
self.PaintThemeSample()
986986
self.SetHighlightTarget()
987987

988-
def __ThemeNameIndexCompare(self,a,b):
989-
if self.themeElements[a][1]<self.themeElements[b][1]: return -1
990-
elif self.themeElements[a][1]==self.themeElements[b][1]: return 0
991-
else: return 1
992-
993988
def LoadKeyCfg(self):
994989
##current keys type radiobutton
995990
self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default',

Lib/idlelib/configHandler.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -642,17 +642,9 @@ def GetExtraHelpSourceList(self,configSet):
642642
helpPath=value[1].strip()
643643
if menuItem and helpPath: #neither are empty strings
644644
helpSources.append( (menuItem,helpPath,option) )
645-
helpSources.sort(self.__helpsort)
645+
helpSources.sort(key=lambda x: x[2])
646646
return helpSources
647647

648-
def __helpsort(self, h1, h2):
649-
if int(h1[2]) < int(h2[2]):
650-
return -1
651-
elif int(h1[2]) > int(h2[2]):
652-
return 1
653-
else:
654-
return 0
655-
656648
def GetAllExtraHelpSourcesList(self):
657649
"""
658650
Returns a list of tuples containing the details of all additional help

0 commit comments

Comments
 (0)