[Tutor] Why doesn't this work?
w chun
wescpy at gmail.com
Tue Jan 24 19:54:32 CET 2006
on a barely related note, sets (mutable [set] and immutable
[frozenset]) were added to Python beginning in version 2.3... so
don't work too hard on your class! you may want to try something more
interesting like:
write a class which let's you keep track of time and does base 60
(sexagesimal / hexasegimal) math:
>>> import myTime
>>> c = myTime.myTime(10,30)
>>> print c
10:30
>>> d = myTime.myTime(8,45)
>>> print c + d
19:15
even better, also allow the constructor to take a string '10:30' in
addition to the integers, and validate the parameters as necessary.
(this is one of the exercises for "Core Python".)
enjoy!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2006,2001
http://corepython.com
wesley.j.chun :: wescpy-at-gmail.com
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
More information about the Tutor
mailing list