View Single Post
Old 10-08-2022, 11:58 AM   #18
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
I am not in favor of making mi subscriptable. Reasons:
  • It could imply that the book object is really a dict, which it isn't.
  • It requires every place that mi is built to implement subscripting. I know of at least 4 places: proxy_metadata, metadata.books, OPF processing, and save_to_disk. I am 90% sure there are more.
  • Adding subscripting is a significant change that could break things. Is the risk worth it?
  • The construction dict.get('key') is basic to python. It shouldn't be a surprise to the user.
  • book.get('title') works, so the user doesn't need to worry about two access methods.
I concur.

Quote:
Originally Posted by chaley View Post
Adding on to the above suggestion about **arguments, how about adding a line to the context menu of the template editor that inserts
Code:
python:
def evaluate(**arguments):
    book = arguments['book']
    db = arguments['db']
This is both a shortcut for typing and aids discoverability.
That is more elegant than what I was trying.
capink is offline   Reply With Quote