View Single Post
Old 09-29-2020, 11:50 AM   #154
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,003
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
New Test Version Attached

Changelog:
Version 1.2.11 - 29 Sep 2020
Better more compatibility with Python 3

Two important things about this:
  1. A book in the library that has never had a series set comes up a little differently than one that had a series at one time, but doesn't anymore. That's why I didn't see it at first.
  2. In Python2, you could compare any two values or variables and value None (of type NoneType) was considered 'less' than anything you compared it with. Python3 incompatibly changed that to 'you can't compare None to anything.
So I, thinking I was clever, changed where this plugin returned None as a default series index to float(-inf), so that it would still be 'less than anything else'.

That's when another pythonic habit bit me--None is always considered False when used in a boolean (as is 0 and empty string('')), so it's common to just do "if var:"

But "if float(-inf):" evaluates to True. Thereby changing the behavior.

So this version returned 0 where it used to be None instead of float(-inf).

Last edited by theducks; 09-30-2020 at 01:01 PM. Reason: moved PI to production
JimmXinu is offline   Reply With Quote