One class for each native Python data-type (example: MyInteger, MyFloat, MyString…). These classes are not substitute of the Python data-types, but they simply provide a template to display the data always as a string in the format of: ‘<data-type> : <value>’
native.py ''' @author: srinivasa ''' class _MyBase: def __init__(self, template, value): print template %value class MyInteger(_MyBase): _template = 'integer : %d' def __init__(self, value): _MyBase.__init__(self, self._template, value) class MyString(_MyBase): _template = 'string : "%s"' def __init__(self, value): _MyBase.__init__(self, self._template, value) if __name__ == '__main__': stringValue = MyString('Aryabhata') integerValue = MyInteger(123)
OUTPUT:
string : "Aryabhata" integer : 123