"momobear" <[EMAIL PROTECTED]> wrote:
> thanks for help:), I am puzzled about if I have to use try and except
> to determine it. finnal code should like this?
> class coffee:
> def __init__(self):
> '''
> do something here
> '''
> def boil(self):
> self.temp = 80
>
> a = coffer()
> try:
> if a.temp > 60:
> print "it's boiled"
> except AttributeError:
> print "it's not boiled"
No, you should simply do the first of the options I suggested. i.e.
initialise the value
class coffee:
def __init__(self):
self.temp = 20
def boil(self):
self.temp = 80
a = coffee()
if a.temp > 60:
print "it's boiled"
else:
print "it's not boiled"
--
http://mail.python.org/mailman/listinfo/python-list