View Single Post
Old 10-08-2022, 01:24 PM   #23
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,488
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by un_pogaz View Post
But maybe it would still be great to put an *args.

We have **arguments (which we rename **data) which contains the basic data related to this book, or anything else we want to provide turnkey to the users.
And on the other side we have *args, which allows to pass arguments to the function during its use, to give it a little more versatility and less "single use". For *args, it's up to the user to program the analysis and the use of the arguments he passed to the function.

Code:
python_template('authors', 'title', 'tags')
python_template('#original_title', '#translator')
Same code, but different output because different input. And if there is a problem, it's because he mismanaged his *args.
You can't call a python template with different arguments. Python templates are not callable by another template; they are callable only by the template processor using a fixed argument list. You can't save a python template as a "Stored template"; those must be GPM templates. If you want to store a callable python function usable by other templates then you define it as a "Template function", where you have control over the args list.

Said another way, a python template is like a GPM template used in an advanced icon rule. It doesn't have a name and is not callable from anywhere else.
chaley is offline   Reply With Quote