Allow updates by using .update() like on a dict #69
Replies: 1 comment
-
That error is caused by The rest of the story is a bit of a long one, grab yourself a cappucino :) TL;DR: change non-trivial, effects finicky, use case peculiar, please elaborate :) As far as remembering things from the documentation (wel... the readme) goes, that's a good one to keep at the back of you mind for sure. The mutability of a First reason is a more philosophical one: the use case for changing configuration values from code at runtime. As long as The second reason stems from the differences in passing things around as either references or values. Due to "Namespaces are one honking great idea -- let's do more of those!", the combination of # option one: use the Configuration object as a first-class citizen (or at least expect some kind of namespace)
def connect_database(db_config):
...
db = connect_database(config.database)
# option two: define things with regular arguments and pass those arguments verbatim from configuration
def connect_database(host, port, username, password):
...
db = connect_database(**config.database)
Lastly, Given all of the above, we could of course still decide this is needed and find neat ways around the stated issues. An implementation of this would at least the following:
I'm personally leaning towards the "Special cases aren't special enough to break the rules"-side of this, but like |
Beta Was this translation helpful? Give feedback.
-
I have remembered approximately one thing from the documenation
Unfortunately, if you try to
update
one like adict
you get a rather cryptic error.So here's my request: support for
dict
-like updating of Configuration objects.Beta Was this translation helpful? Give feedback.
All reactions