Next / Previous / Contents / TCC Help System / NM Tech homepage

41. AccessSummary.genPersonals(): Generate accounts with the same first letter

The first character is used as a key in self.__personalMap; the corresponding value is a Python set of all the personal accounts that start with that character. We generate those account names in ascending order.

webstats.py
# - - -  A c c e s s S u m m a r y . g e n P e r s o n a l s

    def genPersonals ( self, first ):
        '''Generate all personal account names starting with 'first'.
        '''
        #-- 1 --
        # [ if self.__personalMap has a key (first) ->
        #     nameSet  :=  the corresponding value
        #   else -> raise StopIteration ]
        try:
            nameSet  =  self.__personalLetterMap[first]
        except KeyError:
            raise StopIteration

        #-- 2 --
        # [ generate the values in nameSet in ascending order ]
        for name in sorted(nameSet):
            yield name

        #-- 3 --
        raise StopIteration