[Tutor] Time Variable
Remco Gerlich
scarblac@pino.selwerd.nl
Sun, 8 Jul 2001 23:51:08 +0200
On 0, Britt Green <britt_green@hotmail.com> wrote:
> What I'm trying to do is to get a variable that gets updated once every
> second to hold the current time. However, when I write my code, the variable
> gets initialized once, and never again. Can someone point out the error in
> my code?
>
> import time
>
> class GameTime:
> def __init__(self):
> print "Class GameTime initiated."
>
> def updateTime(self, theTime):
> while 1:
> self.theTime = time.ctime(time.time())
> print theTime
This line should be "print self.theTime"
> time.sleep( 1 )
>
> myTime = GameTime()
> myTime.updateTime( time.ctime(time.time()) )
Just remember that theTime and self.theTime are two different variables.
--
Remco Gerlich