#################################################################### # # Method(s) to read specific types from the keyboard. # # Reading a float number from the keyboard. # def read_float(question, minimum=None, maximum=None, default=None): """Read a float value from the command line""" if default is None: value = raw_input(question) else: question += '[%s] ' % default value = raw_input(question) if value == '': value = default value = float(value) # check if the input is within limits if minimum is not None and value < minimum: print 'ERROR: value = ',value,' smaller than minimum',minimum,'.' exit(1) if maximum is not None and value > maximum: print 'ERROR: value = ',value,' larger than maximum',maximum,'.' exit(1) return value