View Single Post
Old 01-17-2011, 09:41 AM   #19
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,458
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pchrist7 View Post
Hi Chaley
I got ambicious. Tried to modify the function code. Want to learn.
I know that feeling. That is why I did the function in the first place
Quote:
Got a weird idea that f > 0 and f < test_val should return Reading,
tried with elif since python apparently doesn't have "case"
...
code:

def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str,
is_not_read_str, no_page_read_str, is_reading_str):
The only difference between your code and mine is that yours returns a different string if the value == 0.

The re.match only succeeds when an annotation is found. That means that the % will be a valid number. Your change returns 'is_reading_str' if that number is > 0 (you know that), and is_not_read_str if that number == 0.

My question: can the number ever be zero? That would imply that the book had been opened but no pages had been turned?
chaley is offline   Reply With Quote