Style for modules with lots of constants
rtw at freenet.co.uk
Wed Nov 1 20:49:28 CET 2006
Paul McGuire wrote in news:KN42h.561$Qn2.495 at tornado.texas.rr.com in
>>> opAssoc = Constants(object)
>>> opAssoc.RIGHT = 0
>>> opAssoc.LEFT = 1
>> This is nice, but you can cut down on some of the cruft:
>> Constants.LEFT = 1
> One man's cruft is another man's clarity.
> The reason I used instances
> instead of just the Constants class was so that I could define a
> little more descriptive context for the constants,
Sorry I don't know what you mean here, could I have an example ?
> rather than simply
> a shortcut for importing lots and lots of constant definitions. I
> expect I will want to define some more constants for other parts of
> pyparsing, and the instance scoping helps organize them, that's all.
Again I'm struggling to see how using an instance is any different from
just using the class ?
More information about the Python-list