No Thoughts about Everything
bblochl
bblochl at fh-lausitz.de
Wed Feb 25 12:25:11 EST 2004
Thanks for any helping suggestions so far.
> If you want something to stay constant,
> just don't change it.
To my regret in programming in large, sometimes distributet groups and
over longer time on a huge Project it is not *my choice* to make the
decision not to change a variable. It is a fact that very often the same
names for variables and so on are used from different persons in an
project, so side effects are only prevented by encapsulation and or make
variables constant. (Usually people use uninspired the ever repeating
x,y, z or a,b,c and so on.)
> class Foo:
> BAR = 10
I tried that in the following in the following prog:
from math import *
class Mytest:
LOGE_10=2.302585092994046
#"Klassenkonstante" (static final?)
#def __init__(self):
def log10(self,x):
return(log(x)/Mytest.LOGE_10)
testmath=Mytest()
print "LOGE_10=%10.8f"%Mytest.LOGE_10," and log10=%f10.8"%testmath.log10(3)
Mytest.LOGE_10=1
print "LOGE_10=%10.8f"%Mytest.LOGE_10," and log10=%f10.8"%testmath.log10(3)
#output:
#LOGE_10=2.30258509 and log10=0.47712110.8
#LOGE_10=1.00000000 and log10=1.09861210.8
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!
Thanks again
Bernhard
PS I will next try to apply recipe 5.15 "Defining Constants" (Alex
Martelli) to LOGE_10 in the class Mytest(). But not today.
More information about the Python-list
mailing list