Next / Previous / Contents / Shipman's homepage

22.5. YearRow.lastMonth(): Return the last month

noteweb
# - - -   Y e a r R o w . l a s t M o n t h

    def lastMonth(self):
        '''Retrieve self's last month, if any.
        '''
        #-- 1 --
        if len(self) == 0:
            raise KeyError

        #-- 2 --
        # [ monthKeyList  :=  month keys in self in ascending order ]
        monthKeyList  =  self.__monthMap.keys()
        monthKeyList.sort()

        #-- 3 --
        # [ return the month number from the last element
        #   of monthKeyList ]
        return self[monthKeyList[-1]].mm