I just looked at Jeremy Hylton's warts posting at <http://starship.python.net/crew/amk/python/writing/warts.html> It reminded me that one feature I really, really want in Python 3000 is the ability to declare constants. Assigning to a constant should raise an error. Is this on the to-do list? -- <a href="http://www.tuxedo.org/~esr">Eric S. Raymond</a> What, then is law [government]? It is the collective organization of the individual right to lawful defense." -- Frederic Bastiat, "The Law"
Correction: It's Andrew Kuchling's list of language warts. I mentioned it in a post on slashdot, where I ventured a guess that the most substantial changes most new users will see with Python 3000 are the removal of these warts. Jeremy
Eric S. Raymond [esr@snark.thyrsus.com] wrote:
I just looked at Jeremy Hylton's warts posting at <http://starship.python.net/crew/amk/python/writing/warts.html>
It reminded me that one feature I really, really want in Python 3000 is the ability to declare constants. Assigning to a constant should raise an error.
Is this on the to-do list?
I know this isn't "perfect", but what I do often is have a Constants.py file that has all my constants in a class which has __setattr__ over ridden to raise an exception. This has two things; 1. Difficult to modify the attributes, at least accidentally 2. Keeps the name-space less poluted by thousands of constants. Just an idea, I think do this: constants = Constants() x = constants.foo Seems clean (reasonably) to me. I think I stole this from the timbot. Chris -- | Christopher Petrilli | petrilli@amber.org
participants (3)
-
Christopher Petrilli
-
Eric S. Raymond
-
Jeremy Hylton