An extendable class that converts strings to object types.


License
Other
Install
pip install stringcoercion==0.0.0.18

Documentation

String Coercion

StringCoercion interprets values typed into the console (or similar text-input) as fields for objects or parameters for functions via PEP484 style reflection.

Object fields or method parameters are reflected and an interpreter generated for each field or parameter. For instance an int field is simply interpreted using int(text).

Please see the Editorium project for the GUI equivalent.

Default interpreters

  • int
  • str
  • Optional
  • bool
  • Enum
  • Flags
  • List or Tuple
  • Password

Note

  • Optional[T] is a PEP484 annotation supplied by Python's Typing library and indicates that a value may be None.
  • Filename is a PEP484 -style annotation provided by the MHelper library and provides hints on an acceptable filename e.g. Filename[".txt", EMode.SAVE].