Functions for handling ISBNs
- pyisbn.calculate_checksum(isbn)[source]
Calculate ISBN checksum.
- Parameters:
- Return type:
- Returns:
Checksum for given ISBN or SBN
>>> 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:
- Return type:
- Returns:
Converted ISBN-10 or ISBN-13
- Raises:
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:
- Return type:
- Returns:
Trueif ISBN is valid
>>> validate('9783540009788') True