18 Feb
2021
18 Feb
'21
6 a.m.
On Wed, Feb 17, 2021 at 11:28:05AM -0800, Brendan Barnwell wrote:
When I see people suggest SimpleNamespace, it's usually just to use it as a dict which is accessed with attribute syntax instead of item syntax.
If its a dict, it must have dict methods. That leads to conflict: data fields and methods collide. A Bunch (see my previous post) or SimpleNamespace doesn't have that problem. A Bunch has no methods (apart from dunders) and so there is no way for them to collide with field names. Things like attrdict, and the Javascript "convenience" short-cut that allows dict key:item pairs to be accessed through attribute syntax, are an attractive nuisance because of that collision problem. -- Steve