stdnum.isbn¶
ISBN (International Standard Book Number).
The ISBN is the International Standard Book Number, used to identify publications. An ISBN is used to identify books. Numbers can either have 10 digits (in ISBN-10 format) or 13 digits (in ISBN-13, EAN compatible format). An ISBN has the following components:
3-digit (only in ISBN-13) Bookland code
1 to 5-digit group identifier (identifies country or language)
1 to 7-digit publisher code
1 to 8-digit item number (identifies the book)
a check digit
More information:
This module also offers functions for converting to ISBN-13 and formatting based on how the number should be split into a bookland code, group identifier, publisher code, item number and check digit.
>>> validate('978-9024538270')
'9789024538270'
>>> validate('978-9024538271')
Traceback (most recent call last):
...
InvalidChecksum: ...
>>> compact('1-85798-218-5')
'1857982185'
>>> format('9780471117094')
'978-0-471-11709-4'
>>> format('1857982185')
'1-85798-218-5'
>>> isbn_type('1-85798-218-5')
'ISBN10'
>>> isbn_type('978-0-471-11709-4')
'ISBN13'
>>> to_isbn13('1-85798-218-5')
'978-1-85798-218-3'
>>> to_isbn10('978-1-85798-218-3')
'1-85798-218-5'
- stdnum.isbn.compact(number, convert=False)¶
Convert the ISBN to the minimal representation. This strips the number of any valid ISBN separators and removes surrounding whitespace. If the convert parameter is True the number is also converted to ISBN-13 format.
- stdnum.isbn.format(number, separator='-', convert=False)¶
Reformat the number to the standard presentation format with the EAN.UCC prefix (if any), the group prefix, the registrant, the item number and the check digit separated (if possible) by the specified separator. Passing an empty separator should equal compact() though this is less efficient. If the convert parameter is True the number is converted to ISBN-13 format first.
- stdnum.isbn.is_valid(number)¶
Check if the number provided is a valid ISBN (either a legacy 10-digit one or a 13-digit one). This checks the length and the check digit but does not check if the group and publisher are valid (use split() for that).
- stdnum.isbn.isbn_type(number)¶
Check the passed number and return ‘ISBN13’, ‘ISBN10’ or None (for invalid) for checking the type of number passed.
- stdnum.isbn.split(number, convert=False)¶
Split the specified ISBN into an EAN.UCC prefix, a group prefix, a registrant, an item number and a check digit. If the number is in ISBN-10 format the returned EAN.UCC prefix is ‘978’. If the convert parameter is True the number is converted to ISBN-13 format first.
- stdnum.isbn.to_isbn10(number)¶
Convert the number to ISBN-10 format.
- stdnum.isbn.to_isbn13(number)¶
Convert the number to ISBN-13 format.
- stdnum.isbn.validate(number, convert=False)¶
Check if the number provided is a valid ISBN (either a legacy 10-digit one or a 13-digit one). This checks the length and the check digit but does not check if the group and publisher are valid (use split() for that).