[Tutor] Time Variable
lumbricus@gmx.net
lumbricus@gmx.net
Mon, 9 Jul 2001 00:17:26 +0200
On Sun, Jul 08, 2001 at 02:24:52PM -0700, Britt Green 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):
^^^^^^^
what for?
> while 1:
> self.theTime = time.ctime(time.time())
^^^^^^^^^^^^^^^^^^^^^
> print theTime
print self.theTime
> time.sleep( 1 )
>
> myTime = GameTime()
> myTime.updateTime( time.ctime(time.time()) )
^^^^^^^^^^^^^^^^^^^^^^^
why?
Greetings J"o!
--
"Give me enough medals, and I'll win any war."
-- Napoleon