def __init__(self, str):
        '''
        Creates ISBN object from a well formed ISBN string
        Raises exception if str is not a valid ISBN
        @type  str: string
        @param str: ISBN Number, either ISBN10 or ISBN13
        '''
        test = _normalize(str)
        self._id = None
        if len(test) == 13 and _digit13(test[:-1]) == int(test[12]):
            if test[0:3] != '978' and test[0:3] != '979':
                raise ISBNError("Invalid Bookland code: {}".format(test[0:3]))
            self._id = test
        if len(test) == 10:
            digit10 = _digit10(test[:-1])
            if digit10 == 10 and test[9] == 'X':
                self._id = '978' + test[:-1] + \
                    repr(_digit13('978' + test[:-1]))
            if test[9] != 'X' and digit10 == int(test[9]):
                self._id = '978' + test[:-1] + \
                    repr(_digit13('978' + test[:-1]))
        if not self._id:
            raise ISBNError("Invalid ISBN check digit: {}".format(str))
def __init__ ( self , str ) : test = _normalize ( str ) self . _id = None if len ( test ) == 13 and _digit13 ( test [ : - 1 ] ) == int ( test [ 12 ] ) : if test [ 0 : 3 ] != '978' and test [ 0 : 3 ] != '979' : raise ISBNError ( "Invalid Bookland code: {}" . format ( test [ 0 : 3 ] ) ) self . _id = test if len ( test ) == 10 : digit10 = _digit10 ( test [ : - 1 ] ) if digit10 == 10 and test [ 9 ] == 'X' : self . _id = '978' + test [ : - 1 ] + repr ( _digit13 ( '978' + test [ : - 1 ] ) ) if test [ 9 ] != 'X' and digit10 == int ( test [ 9 ] ) : self . _id = '978' + test [ : - 1 ] + repr ( _digit13 ( '978' + test [ : - 1 ] ) ) if not self . _id : raise ISBNError ( "Invalid ISBN check digit: {}" . format ( str ) )
Creates ISBN object from a well formed ISBN string
        Raises exception if str is not a valid ISBN
        @type  str: string
        @param str: ISBN Number, either ISBN10 or ISBN13