Universal collection of a bunch of named stuff.
Often we want to just collect a bunch of stuff together, naming each item of the bunch. A dictionary is OK for that; however, when names are constants and to be used just like variables, the dictionary-access syntax (“if bunch[‘squared’] > threshold”, etc) is not maximally clear. It takes very little effort to build a little class, as in this ‘Bunch’, that will both ease the initialisation task and provide elegant attribute-access syntax (“if bunch.squared > threshold”, etc).
Usage is simple:
point = eg.Bunch(x=100, y=200) # and of course you can read/write the named # attributes you just created, add others, del # some of them, etc, etc: point.squared = point.x * point.y if point.squared > threshold: point.isok = True