On Mon, Mar 04, 2019 at 11:56:54AM -0600, Dan Sommers wrote:
On 3/4/19 10:44 AM, Steven D'Aprano wrote:
If you know ahead of time which order you want, you can simply reverse it:
# prefs = site_defaults + user_defaults + document_prefs prefs = dict(ChainMap(document_prefs, user_defaults, site_defaults))
but that seems a little awkward to me, and reads backwards. I'm used to thinking reading left-to-right, not right-to-left.
I read that as use document preferences first, then user defaults, then site defautls, exactly as I'd explain the functionality to someone else.
If you explained it to me like that, with the term "use", I'd think that the same feature would be done three times: once with document prefs, then with user defaults, then site defaults. Clearly that's not what you mean, so I'd then have to guess what you meant by "use", since you don't actually mean use. That would leave me trying to guess whether you meant that *site defaults* overrode document prefs or the other way. I don't like guessing, so I'd probably explicitly ask: "Wait, I'm confused, which wins? It sounds like site defaults wins, surely that's not what you meant."
So maybe we're agreeing: if you think in terms of updating a dictionary of preferences, then maybe it reads backwards, but if you think of implementing features, then adding dictionaries of preferences reads backwards.
Do you think "last seen wins" is backwards for dict.update() or for command line options? -- Steven