No Thoughts about Everything

Max M maxm at mxm.dk
Thu Feb 26 04:14:07 EST 2004


bblochl wrote:

> I tried that in the following in the following prog:
> 
> class Mytest:
>   LOGE_10=2.302585092994046
>   #"Klassenkonstante" (static final?)
>   #def __init__(self):
>          def log10(self,x):
>       return(log(x)/Mytest.LOGE_10)
> 
> One can see that one can change the constant LOGE_10 without any 
> problem! So it is weather in Theory nor in practice a constant? That is 
> not the needed functionality. Or did I not understand your proposes 
> concept and did something wrong in the code ?
> 
> I am very thankful for any help to solve that central problem!

Personally I don't find the issue is that important. I have not 
experienced in practice that ALL_CAPS wasn't enough of a convention not 
to change a variable.

But I think that this will make shure that there *is* problems when 
changing LOGE_10::

LOGE_10 = lambda: 2.302585092994046
print LOGE_10()

LOGE_10 = 42
print LOGE_10()


 >>2.30258509299
 >>Traceback (most recent call last):
   File "E:\maxm\pys\x.py", line 5, in ?
     print LOGE_10()
TypeError: 'int' object is not callable




regards Max M



More information about the Python-list mailing list