':type str: str
:rtype: bool'

def repeatedSubstringPattern(self, str):

    def getPrefix(pattern):
        prefix = ([(-1)] * len(pattern))
        j = (-1)
        for i in xrange(1, len(pattern)):
            while ((j > (-1)) and (pattern[(j + 1)] != pattern[i])):
                j = prefix[j]
            if (pattern[(j + 1)] == pattern[i]):
                j += 1
            prefix[i] = j
        return prefix
    prefix = getPrefix(str)
    return ((prefix[(-1)] != (-1)) and (((prefix[(-1)] + 1) % ((len(str) - prefix[(-1)]) - 1)) == 0))
