declare a constant in Python?
dave at pythonapocrypha.com
Thu Sep 9 20:05:38 CEST 2004
beliavsky at aol.com wrote:
> I wish one could declare a constant in Python, analogous to 'const int
> i=1;' in C++. Is there a way to get this effect?
With a bit of work, yes - Google will turn up some recipes for it.
It's basically never worth the effort because in practice it offers no advantage
over just a naming convention (i.e. nobody accidentally rebinds their values, so
doing that extra work doesn't provide any practical benefit).
More information about the Python-list