On Tue, Jul 24, 2018, 7:38 AM Rhodri James
Every use I've suggested for the magic proxy is similar to:
NullCoalesce(cfg).user.profile.food
Yes, the class is magic. That much more so in the library I published last night that utilizes wrapt.ObjectProxy. But it's also pretty explicit in that an actual*word* announces that funny stuff is going to happen on
On 24/07/18 12:02, David Mertz wrote: the
same line.
Foo(cfg).user.profile.food
Is that explicit that funny stuff is going to happen on the same line? I wouldn't generally assume so, I'd just assume the coder created a throwaway object to get at an attribute.
Foo isn't a very indicative name. NoneCoalesce (or NullCoalesce, or GreedyAccess) is. But if I had any doubt, I could read the docstring for Foo to find out how magical it was, and in what way. I definitely know *something* is happening by creating that new instance in the line. I'm still of the opinion that both approaches are trying to solve a
problem that's too niche to merit them, BTW.
That doesn't make sense to me. You think my little library shouldn't be allowed on PyPI? I don't force the couple classes on anyone, but if they happen to help someone (or PyMaybe, or some other library, does) they don't change anything about Python itself. Syntax is a very different matter.