From 25bf597031e3de0cadfe3298570af29e4c20de25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Wed, 29 Jan 2014 22:16:10 +0000 Subject: common: fix namedtuple usage to allow for optional parameters. The otultraeasy does not provide comments or meal indications. --- glucometerutils/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/glucometerutils/common.py b/glucometerutils/common.py index 38f735e..a9968c2 100644 --- a/glucometerutils/common.py +++ b/glucometerutils/common.py @@ -54,7 +54,7 @@ _ReadingBase = collections.namedtuple( '_ReadingBase', ['timestamp', 'value', 'meal', 'comment']) class Reading(_ReadingBase): - def __init__(self, timestamp, value, meal='', comment=''): + def __new__(cls, timestamp, value, meal='', comment=''): """Constructor for the reading object. Args: @@ -67,8 +67,8 @@ class Reading(_ReadingBase): because at least most of the LifeScan devices report the raw data in this format. """ - super(Reading, self).__init__( - timestamp=timestamp, value=value, meal=meal, comment=comment) + return super(Reading, cls).__new__( + cls, timestamp=timestamp, value=value, meal=meal, comment=comment) def get_value_as(self, to_unit): """Returns the reading value as the given unit. -- cgit v1.2.3