creating instances of classes?
Matthias Huening
matthias.huening at univie.ac.at
Thu Mar 9 05:59:32 EST 2000
Shaun Hogan wrote:
>i want the code below to tell me the current time & date when i execute it,
>i dont know how to make an instace of telltime though, can anyone correct
>if for me.
class telltime:
def __init__(self):
import time
z = time.time()
# you can of cours change the format...
self.time = time.strftime("%H:%M", time.localtime(z))
self.date= time.strftime("%d.%m.%Y", time.localtime(z))
def op(self):
print self.time
print self.date
t=telltime()
t.op()
Cheers, Matthias
- - - - -
matthias.huening at univie.ac.at
http://www.ned.univie.ac.at/
More information about the Python-list
mailing list