trafaret.constructor — methods to access object’s attribute/netsted key by path

class trafaret.constructor.C

Start object. It has | and & operations defined that will use construct to it args

Use it like C & int & check_less_500


Shortcut syntax to define trafarets.

  • int, str, float and bool will return t.Int, t.String, t.Float and t.Bool
  • one element list will return t.List
  • tuple or list with several args will return t.Tuple
  • dict will return t.Dict. If key has ‘?’ at the and it will be optional and ‘?’ will be removed
  • any callable will be t.Call
  • otherwise it will be returned as is

construct is recursive and will try construct all lists, tuples and dicts args