Hi,
I am trying to create a cutom 'Float' type using built in 'float' type. Here is the code:
class Attribute(object):
"""
Common attributes and methods for custom types
"""
def __init__(self, name=None, type=None, range=None):
self.__name = name
self.__type = type
self.__range = range
#Read only attributes
name = property(lambda self: self.__name)
type = property(lambda self: self.__type)
range = property(lambda self: self.__range)
class Float(float, Attribute):
'''Custom Float type'''
__slots__ = ('__name', '__type', '__range')
def __init__(self, value=0.0, name=None, type=None, range=(0.0, 1.0)):
try:
super(Float, self).__init__(name=name, type=type, range=range)
float.__init__(self, value)
except:
print 'Error : %s %s' % sys.exc_info()[:2]
a = Float(2.0, name='myFloat')
The problem is, I am not able to pass arguments when creating an instance. How do I solve this?