Да все уже, все понял :) Всем спасибо :)
from turbogears import validators, util
import formencode
class Number(formencode.validators.Number):
messages = {
‘number’: ‘Введите число’,
}
def _to_python(self, value, state):
“”“ parse a string and returns a float or integer ”“”
try:
value = validators.format.parse_decimal(value)
except ValueError:
pass
return super(Number, self)._to_python(value, state)
def _from_python(self, value, state):
“”“ returns a string using the correct grouping ”“”
dec_places = util.find_precision(value)
if dec_places > 0:
return validators.format.format_decimal(value, dec_places)
else:
return validators.format.format_number(value)
v = Number()
tt=v.to_python('tt')