'Return the list of messages currently present in the folder.
As a side effect, set self.last to the last message (or 0).'

def listmessages(self):

    messages = []
    match = numericprog.match
    append = messages.append
    for name in os.listdir(self.getfullname()):
        if match(name):
            append(name)
    messages = map(int, messages)
    messages.sort()
    if messages:
        self.last = messages[(-1)]
    else:
        self.last = 0
    return messages
