Sujet : Re: Configuring an object via a dictionary
De : loris.bennett (at) *nospam* fu-berlin.de (Loris Bennett)
Groupes : comp.lang.pythonDate : 18. Mar 2024, 07:42:32
Autres entêtes
Organisation : FUB-IT (ex-ZEDAT), Freie Universität Berlin
Message-ID : <875xxk2g87.fsf@zedat.fu-berlin.de>
References : 1 2 3
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Tobiah <
toby@tobiah.org> writes:
I should mention that I wanted to answer your question,
but I wouldn't actually do this. I'd rather opt for
your self.config = config solution. The config options
should have their own namespace.
>
I don't mind at all referencing foo.config['option'],
or you could make foo.config an object by itself so
you can do foo.config.option. You'd fill it's attributes
in the same way I suggested for your main object.
Thanks for the thoughts. I'll go for self.config = config after
all, since, as you say, the clutter caused by the referencing is not
that significant.
Cheers,
Loris
-- This signature is currently under constuction.