| Home | Trees | Indices | Help |
|---|
|
|
object --+
|
basevalidator.BaseValidator --+
|
ToType --+
|
ToInt
Convert a value to an integer.
While you could just use int, this throws a much nicer error message.
For example:
>>> v = ToInt() >>> v(1) 1 >>> v(2.3) 2 >>> v('foo') Traceback (most recent call last): ... ValueError: can't convert 'foo' to integer
|
|||
|
|||
|
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 |