always call base constructor of CapBaseObject to prevent shared fields
This commit is contained in:
parent
9a416cb7bc
commit
c5ee2aec2a
1 changed files with 3 additions and 2 deletions
|
|
@ -33,6 +33,7 @@ class Temperature(CapBaseObject):
|
|||
unit = StringField('Input unit')
|
||||
|
||||
def __init__(self, value, unit = u''):
|
||||
CapBaseObject.__init__(self, value)
|
||||
self.value = value
|
||||
if unit not in [u'C', u'F']:
|
||||
unit = u''
|
||||
|
|
@ -42,7 +43,7 @@ class Temperature(CapBaseObject):
|
|||
if not self.unit:
|
||||
return u'%s' % int(round(self.value))
|
||||
elif self.unit == 'F':
|
||||
return u'%sF' % int(round(self.value))
|
||||
return u'%s°F' % int(round(self.value))
|
||||
else:
|
||||
return u'%s°F' % int(round((self.value * 9.0 / 5.0) + 32))
|
||||
|
||||
|
|
@ -50,7 +51,7 @@ class Temperature(CapBaseObject):
|
|||
if not self.unit:
|
||||
return u'%s' % int(round(self.value))
|
||||
elif self.unit == 'C':
|
||||
return u'%sC' % int(round(self.value))
|
||||
return u'%s°C' % int(round(self.value))
|
||||
else:
|
||||
return u'%s°C' % int(round((self.value - 32.0) * 5.0 / 9.0))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue