Functions for handling ISBNs

pyisbn.calculate_checksum(isbn)[source]

Calculate ISBN checksum.

Parameters:isbn (str) – SBN, ISBN-10 or ISBN-13
Returns:Checksum for given ISBN or SBN
Return type:str
>>> calculate_checksum('978354000978')
'8'
pyisbn.convert(isbn, code='978')[source]

Convert ISBNs between ISBN-10 and ISBN-13.

Note

No attempt to hyphenate converted ISBNs is made, because the specification requires that any hyphenation must be correct but allows ISBNs without hyphenation.

Parameters:
  • isbn (str) – SBN, ISBN-10 or ISBN-13
  • code (str) – EAN Bookland code
Returns:

Converted ISBN-10 or ISBN-13

Return type:

str

Raise:
IsbnError: When ISBN-13 isn’t convertible to an ISBN-10
>>> convert('9783540009788')
'3540009787'
pyisbn.validate(isbn)[source]

Validate ISBNs.

Warning

Publishers have been known to go to press with broken ISBNs, and therefore validation failures do not completely guarantee an ISBN is incorrectly entered. It should however be noted that it is massively more likely you have entered an invalid ISBN than the published ISBN is incorrectly produced. An example of this probability in the real world is that Amazon consider it so unlikely that they refuse to search for invalid published ISBNs.

Parameters:isbn (str) – SBN, ISBN-10 or ISBN-13
Returns:True if ISBN is valid
Return type:bool
>>> validate('9783540009788')
True