Home | Trees | Indices | Help |
---|
|
object --+ | basevalidator.BaseValidator --+ | ToType --+ | ToFloat
Convert a value to a float.
While you could just use float, this throws a much nicer error message.
For example:
>>> v = ToFloat() >>> v(1.0) 1.0 >>> v(2) 2.0 >>> v('foo') Traceback (most recent call last): ... ValueError: can't convert 'foo' to float
|
|||
|
|||
Inherited from Inherited from Inherited from |
|
|||
Inherited from |
|
Class c'tor, accepting a type. For example: >>> v = ToType(int, type_name='an integer') >>> v(1) 1 >>> v(2.3) 2 >>> v('foo') Traceback (most recent call last): ... ValueError: can't convert 'foo' to an integer >>> v = ToType(float) >>> v('foo') Traceback (most recent call last): ... ValueError: can't convert 'foo' to float
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Jul 22 15:13:46 2011 | http://epydoc.sourceforge.net |