File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
source_py2/python_toolbox Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -358,7 +358,7 @@ def decimal_number_from_string(string):
358358 '''
359359 if isinstance (string , bytes ):
360360 string = string .decode ()
361- if not isinstance (string , str ):
361+ if not isinstance (string , basestring ):
362362 raise Exception ("%s isn't a decimal number." % string )
363363 if not _decimal_number_pattern .match (string ):
364364 raise Exception ("%s isn't a decimal number." % string )
Original file line number Diff line number Diff line change 1414
1515class OrderedDict (StdlibOrderedDict ):
1616
17+ def move_to_end (self , key , last = True ):
18+ '''Move an existing element to the end (or beginning if last==False).
19+
20+ Raises KeyError if the element does not exist.
21+ When last=True, acts like a fast version of self[key]=self.pop(key).
22+
23+ '''
24+ link = self .__map [key ]
25+ link_prev = link [0 ]
26+ link_next = link [1 ]
27+ link_prev [1 ] = link_next
28+ link_next [0 ] = link_prev
29+ if last :
30+ last = self .__root [0 ]
31+ link [0 ] = last
32+ link [1 ] = self .__root
33+ last [1 ] = self .__root [0 ] = link
34+ else :
35+ first = self .__root [1 ]
36+ link [0 ] = self .__root
37+ link [1 ] = first
38+ root [1 ] = first [0 ] = link
39+
1740 def sort (self , key = None , reverse = False ):
1841 '''
1942 Sort the items according to their keys, changing the order in-place.
You can’t perform that action at this time.
0 commit comments