Help with code
Dmitry Savchuk
compedu at nh.km.ua
Wed Feb 20 04:01:36 EST 2002
Hi,
I'd like to ask you a question. There is a code from the book of Ivan Van
Laningham "Sams Teach Yourself Python in 24 Hours (Teach Yourself -- 24
Hours)":
import time
class now:
def _init_(self):
self.t=time.time()
self.storetime()
def storetime(self):
self.year,\
self.month,\
self.day,\
self.hour,\
self.minute,\
self,second,\
self.dow,\
self.doy,\
self,dst=time.localtime(self.t)
def _str_(self):
return time.ctime(self.t)
n=now()
print "The year is ", n.year
print n
s=`n`
print s
It doesn't work properly. Appear a messge:
The year is
Traceback (most recent call last):
File "C:\Projects\test", line 20, in ?
print "The year is ", n.year
AttributeError: now instance has no attribute 'year'
Where is my mistake?
Thak you in advance.
Dmitry Savchuk.
More information about the Python-list
mailing list