Next / Previous / Contents / Shipman's homepage

22.4. YearRow.firstMonth(): Return the first month

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

    def firstMonth(self):
        '''Retrieve self's first month number, 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 first element
        #   of monthKeyList ]
        return self[monthKeyList[0]].mm