| Home | Trees | Indices | Help |
|---|
|
|
object --+
|
basevalidator.BaseValidator --+
|
ToType --+
|
ToStr
Convert a value to a string.
While you could just use str, this throws a much nicer error message.
For example:
>>> v = ToStr()
>>> v(1.0)
'1.0'
>>> v('foo')
'foo'
|
|||
|
|||
|
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 |