Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > No Thoughts about Everything

Reply
Thread Tools

No Thoughts about Everything

 
 
bblochl
Guest
Posts: n/a
 
      02-26-2004
I found a solution for the simulation of access modifier "static final "
in python:


class Mytest:
LOGE_10=(2.302585092994046,)
#Klassenkonstante (static final) use a tuple
#def __init__(self):

def log10(self,x):
return(log(x)/LOGE_10[0])

testmath=Mytest()
print "LOGE_10=%10.8f"%Mytest.LOGE_10[0]," and
log10=%f10.8"%testmath.log10(3)
Mytest.LOGE_10[0]=1
#print "LOGE_10=%10.8f"%Mytest.LOGE_10[0]," and
log10=%f10.8"%testmath.log10(3)


#output:
#LOGE_10=2.30258509 and log10=0.47712110.8
#Traceback (most recent call last):
# File
"C:\Python22\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py" ,
line 301, in RunScript
# exec codeObject in __main__.__dict__
# File "C:\PyProgs\Static.py", line 13, in ?
# #Mytest.LOGE_10=1
#TypeError: object doesn't support item assignment
#

I think the result is selfexplaining. Unawaited there is another
argument for tuples! One may use it for the definition of global
"Constants" as well.

Hopefully that contribution will be of interest and profit for other
python users. Thanks for your contributions.

Bernhard

PS: Has everyone tried to use classes as elements of tuples? please give
me a hint.


 
Reply With Quote
 
 
 
 
Paul Rubin
Guest
Posts: n/a
 
      02-26-2004
bblochl <(E-Mail Removed)> writes:
> I found a solution for the simulation of access modifier "static final
> " in python:
>
>
> class Mytest:
> LOGE_10=(2.302585092994046,)
> #Klassenkonstante (static final) use a tuple
> #def __init__(self):
> def log10(self,x):
> return(log(x)/LOGE_10[0])
>
> testmath=Mytest()


But you can still change the value by saying

testmath.LOGE_10 = (3.14159,)

outside the class definition.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not Quite Everything for a Theory of Everything fitz VOIP 0 02-28-2010 04:42 PM
FIREFOX IS GREAT, EVERYTHING WILL LOAD Big Craigie Firefox 4 04-21-2005 12:38 AM
Firefox 1.0 "Looking up" everything, not finding it. s... Firefox 2 01-03-2005 08:34 AM
No Thoughts about Everything b-blochl Python 5 02-29-2004 03:48 AM
Re: No Thoughts about Everything Dave Brueck Python 3 02-26-2004 06:09 PM



Advertisments