python 3 constant

Waldek M. wm at localhost.localdomain
Thu Jun 23 07:58:08 EDT 2011


Dnia Thu, 23 Jun 2011 17:22:37 +1000, Ben Finney napisał(a):
> If you mean creating a binding which can't be re-bound: −1.

Perhaps. Or perhaps that could be done in some other fashion;
I admit that I usually stick to more strict languages
and while Python's flexibility is great... I'm really missing
constants.

> The ability to re-bind any attribute, even ones which the author thought
> should be constant, makes writing unit tests much easier. I don't see
> that putative benefits of constant bindings would be anywhere near as
> valuable.

Primo, isn't it usually the author that does the unit testing?
Anyway, correct me if I'm wrong but I always thought that unit tests
should prove the correctness and quality of the code under test,
and not the other way around, which would be sacrifising
code security to make testing easier.

Secundo, one can say that re-binding gives the freedom to change
what one likes; I'd say that I'd also like the freedom to decide what
is mutable and what is not.

Of course, it is just my personal opinion. It might be not pythonic,
I may be wrong, yet - concept of constants is not something new and
if other languages, like C/C++/Java/Perl/ (bash even) have them, 
I can't see the reason not to have them in Python.

Best regards,
Waldek



More information about the Python-list mailing list