Home | Trees | Indices | Help |
|
---|
|
object --+ | Autoconverter
Automatically convert an input value to a special python object. The :meth:`Autoconverter.convert` method turns the value into a special python value and casts strings to the "best" type (see :func:`besttype`). The defaults for the conversion of a input field value to a special python value are: =========== =============== value python =========== =============== '---' ``None`` 'none' 'None' '' 'True' ``True`` 'x' 'X' 'yes' 'False' ``False`` '-' 'no' =========== =============== If the *sep* keyword is set to a string instead of ``False`` then values are split into tuples. Probably the most convenient way to use this is to set *sep* = ``True`` (or ``None``) because this splits on all white space whereas *sep* = ' ' would split multiple spaces. **Example** - With *sep* = ``True``: 'foo bar 22 boing ---' --> ('foo', 'boing', 22, None) - With *sep* = ',': 1,2,3,4 --> (1,2,3,4)
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
active = property(** active())
|
|
|||
Inherited from |
|
Initialize the converter. :Arguments: *mode* defines what the converter does "simple" convert entries with :func:`besttype` "singlet" convert entries with :func:`besttype` and apply mappings "fancy" first splits fields into lists, tries mappings, and does the stuff that "singlet" does "unicode" convert all entries with :func:`to_unicode` *mapping* any dict-like mapping that supports lookup. If``None`` then the hard-coded defaults are used *active* or *autoconvert* initial state of the :attr:`Autoconverter.active` toggle. ``False`` deactivates any conversion. [``True``] *sep* character to split on (produces lists); use ``True`` or ``None`` (!) to split on all white space. *encoding* encoding of the input data [utf-8]
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Jun 3 22:23:16 2010 | http://epydoc.sourceforge.net |