Thanks for making this useful library available. While trying to filter invalid isbns from a list of 999 items with a function that calls pyisbn.validate(), the operation failed because some isbns were less than 10 digits. However, each subsequent call to pyisbn.validate() kept returning (after the boolean) parts of the previous list. See output 82 - 91. Any idea why?
In [81]: testresult = filter(v, test)
---------------------------------------------------------------------------
IsbnError Traceback (most recent call last)
<ipython-input-81-519d0e9e2e9c> in <module>()
----> 1 testresult = filter(v, test)
<ipython-input-72-31b0fb728e9e> in v(x)
1 def v(x):
----> 2 return not(pyisbn.validate(x))
c:\python27\lib\site-packages\pyisbn\__init__.pyc in validate(isbn)
420
421 """
--> 422 isbn = _isbn_cleanse(isbn)
423 return isbn[-1].upper() == calculate_checksum(isbn[:-1])
c:\python27\lib\site-packages\pyisbn\__init__.pyc in _isbn_cleanse(isbn, checksum)
337 raise IsbnError('non-digit checksum')
338 else:
--> 339 raise IsbnError('ISBN must be either 10 or 13 characters long')
340 else:
341 if len(isbn) == 8:
IsbnError: ISBN must be either 10 or 13 characters long
1149684", "9780691122700", "9780841225695", "9781847552594", "9780841225435", "9780470547847", "9780521876285", "978-143
In [82]: pyisbn.validate("691147949")
Out[82]: True9780534493493", "9780321750891", "9781118017166", "123849888", "9780521736534", "978-0415306362", "98718426
55207", "9780578026152", "978-1849801157", "9781577666936", "9781560328582", "9780854041763", "978-1845426606", "9781890
In [83]: pyisbn.validate("691d147949")
---------------------------------------------------------------------------05032280", "9781592330409", "978091125770", "
IsbnError Traceback (most recent call last)36128663", "9789814280143", "9780205424177",
<ipython-input-83-e8f3bd933b41> in <module>()396", "9783631566152", "9780470598801", "9789812771759", "9780521674423", "
----> 1 pyisbn.validate("691d147949")-0470927076", "9780521877015", "470129239", "9780470129234", "9780205402878", "9781
565939790", "470484098", "9789814322249", "9789812561992", "978-1597496599", "978-0231101332", "9781890627706", "9780470
c:\python27\lib\site-packages\pyisbn\__init__.pyc in validate(isbn)3208496", "9781848729018", "9780763754006", "97807637
420 "9780415774680", "9780521182491", "3527410392", "978-1111578718", "9781848167582", "978-1571170576", "9789812700
421 """01703", "9781413015898", "9780631197119", "9780415520683", "9780470585894", "9781405124416", "97814027682
--> 422 isbn = _isbn_cleanse(isbn) "9781107403758", "9783642107092", "9789812837516", "9780131395060", "978-00729219
423 return isbn[-1].upper() == calculate_checksum(isbn[:-1])2101", "9781107004528", "9781849730914", "9780813817
910", "9781555815363", "471215023", "9781849730525", "9781597560368", "9780415605250", "9789814291675", "9780521856980",
c:\python27\lib\site-packages\pyisbn\__init__.pyc in _isbn_cleanse(isbn, checksum)9", "1597497258", "9789812383068", "97
326 raise TypeError('ISBN must be a string, received %r' % isbn)49633", "9781848166813", "9781555814816", "9
327 if not isbn[:-1].isdigit():571172129", "9781592579020", "9780737750836", "9780970245823", "9781107010468", "
--> 328 raise IsbnError('non-digit parts') "9789814295772", "1555815030", "1842651196", "9780840054449", "978084
329 if checksum:", "1842653989", "9780471757399", "9781111425562", "9781111573997", "9781111573980", "9780538733
330 if len(isbn) == 9:", "9781842652961", "9780521761314", "9781618120120", "9780954699918", "9780199561797"
, "9780470627761", "9781848165601", "9780309158954", "9780763784508", "9780194372398", "9780805804669", "9780199564811",
IsbnError: non-digit parts166042", "9780691074535", "9781847355560", "9781555616049", "9780691128610", "9781577663485",
"9780854049561", "9780470616912", "9781847552259", "9780521864299", "9780854044665", "9781847350930", "9781847350954", "
In [84]: pyisbn.validate("6912147949")
Out[84]: False "9780521513692", "9789814293761", "9780840049315", "9781842656242", "9780195171693", "9781842652466", "97
89812388582", "9789812565280", "9781592333219", "9780981604558", "9789812561121", "9780309160353", "978-1593701390", "15
In [85]: pyisbn.validate("6912147949")
Out[85]: False71170453", "9781847552402", "9780521518192", "9789812778987", "9781603560085", "9780309137164", "978981277
1131", "9781107009653", "978-1571172013", "978-1571172044", "978-1571172020", "978-0692000274", "9780309187510", "978184
In [86]: pyisbn.validate("6912147949")
Out[86]: False9814329835", "9781555816612", "9780314911612", "9781107403505", "9781602391246", "978-1613504444", "978-11
19993056", "9781599290591", "9780863775697", "9780521899543", "978-9064507434", "9780521699099", "9789814355506", "12382
In [87]: pyisbn.validate("978-0262062664")
Out[87]: True47355591", "9780521651516", "9780470623961", "9780470624296", "9781118156438", "9780312586300", "978-906450
6482", "9781401323448", "9780425213575", "978-1571172143", "978-1571171986", "0-57117-072-3", "978-1571172051", "978-052
In [88]: pyisbn.validate("978-0262062664")
Out[88]: True1848720398", "978-0517562208", "978-1848448346", "9780309138505", "978-9064506710", "9780983490708", "97806
91149493", "1597496618", "1597496537", "9781930448360", "9780521138178", "9781107013469", "9781578263097", "978089529817
In [89]: pyisbn.validate("978-0262062664")
Out[89]: True"9780691131382", "9780691144146", "9780805077469", "9780470538708", "9780674403451", "9781453837085", "9780
691142890", "052117533X", "9780415882194", "9780345494580", "9781568989723", "9789812560421", "9780982290040", "97811080
In [90]: pyisbn.validate("978-0262062664")
Out[90]: True80217371858", "9781594868283", "9781107401648", "9781569242742", "9781848166011", "9780470455753", "9780452
296886", "9780195128987", "9781594770951", "9780312376321", "9781573317566", "9780520202535", "9781859574980", "97805211
In [91]: pyisbn.validate("981429134X")
Out[91]: True02458", "9780309148504", "9781849800204", "9781849730433", "9781849730433", "9789812560889", "9780071636919
", "9780309148382", "9780470655887", "978-1847202055", "9780123814753", "9780970245816", "9780446690744", "9789814295512
In [92]: testresult
Out[92]: []
In [93]: pyisbn.validate("981429134X")
Out[93]: True
In [94]: pyisbn.validate("981429234X")
Out[94]: False