On Tue, Feb 27, 2018 at 1:41 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > I have a class with a large number of parameters (about ten) assigned in > `__init__`. The class then has a number of methods which accept > *optional* arguments with the same names as the constructor/initialiser > parameters. If those arguments are None, the defaults are taken from the > instance attributes.
I have a very similar problem in a project of mine, and it's currently an unsolved problem. My current best theory is to basically just accept **kwargs for everything (so there's no None defaults), and then use chain_map for all lookups. Seems inefficient, but at least it'd be functional. Haven't implemented it though. If you get any better ideas, I'll be reading them too. ChrisA -- https://mail.python.org/mailman/listinfo/python-list