View Single Post
Old 02-21-2021, 02:35 PM   #356
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,203
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by chaley View Post
Good idea. I have used the calibre built-in version of this function many times. Are you using it to do the implementation? It is calibre.db.cache.get_categories. It supports a list of book ids, does caching, and has several other optimizations. It returns a dict
Yes. I am using this for the function. I wouldn't have done it without the get_categories().

Quote:
Originally Posted by chaley View Post
I can do this. The big question is how? What I would prefer to do is extend the language for the for statement, making its grammar
Code:
'for' varname 'in' expression ['separator' expression] ':'
I leave this to you. What you suggests would work nicely for me.

Quote:
Originally Posted by chaley View Post
Specifying the separator is optional. OK with you?
Definitely. It is better not to force people to specify the separator every time unnecessarily.

Quote:
Originally Posted by chaley View Post
However, I realize that this use of list_union is rather esoteric, so I will add the function
Code:
list_remove_duplicates(list, sep)
If you think that list_uniq(), or perhaps list_unique(), is a better name than I can use that.
Yours seems more descriptive and better.
capink is offline   Reply With Quote