View Single Post
Old 04-11-2020, 03:25 AM   #16
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,738
Karma: 24031403
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by carmenchu View Post
I have implemented a variant of your suggestion, and (I hope!) avoided the trouble of a void "tags": "", getting the "tags" preferences obliterated on next run.
Unfortunately,
Code:
ttags = [True,prefs['tags'].split(',')][len(prefs['tags']) > 0 or 0] # evaluates to 1|0 for tags|no tags
doesn't work for empty strings. Since it was my idea anyway, simply remove the part that checks for empty strings.

Quote:
Originally Posted by carmenchu View Post
It's an option which I wouldn't recommend, save for report purposes: one can achieve the same result by a simple search & replace of class="calibre\d*"
Indeed. Maybe it isn't a good idea to have such an option.

Quote:
Originally Posted by carmenchu View Post
By the way, is there a simple way of getting the list of tags ordered? It would be easier to read and edit, but I can't get it done...
The built-in sort() function should also work for lists.

BTW, one other free Python book I can highly recommend is Automate the Boring Stuff with Python by Al Sweigart, which is available online and as a paid e-book.
Doitsu is offline   Reply With Quote