[Tutor] output question

Kent Johnson kent37 at tds.net
Sat Oct 15 03:00:30 CEST 2005


Shi Mu wrote:
> After I run the following python code, I expect to have the printing such as:
> The year is 2005
> 
> However, I got something like:
> The year is 2005
> Fri Oct 14 17:43:31 2005
> Fri Oct 14 17:43:31 2005
> The year is 2005
> 
> What is the reason?

Maybe coming from module 'now'? What is that?

Kent

> 
> The code follows:
> 
> import time
> import now
> 
> class today(now.now):
>     def __init__(self, y = 1970):
> 	now.now.__init__(self)
>     def update(self,tt):
> 	if len(tt) < 9 :
> 	    raise TypeError
> 	if tt[0] < 1970 or tt[0] > 2038:
> 	    raise OverflowError
> 	self.t = time.mktime(tt)
> 	self(self.t)
> 
> if __name__ == "__main__":
>     n = today()
>     print "The year is", n.year
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 



More information about the Tutor mailing list