code: def as_template(value):
      
      if isinstance(value, Template):
          # If it's already a Template, pass it through.
          return value
      elif isinstance(value, abc.Mapping):
          # Dictionaries work as templates.
          return MappingTemplate(value)
      elif value is int:
          return Integer()
      elif isinstance(value, int):
          return Integer(value)
      elif isinstance(value, type) and issubclass(value, BASESTRING):
          return String()
      elif isinstance(value, BASESTRING):
          return String(value)
      elif isinstance(value, set):
          # convert to list to avoid hash related problems
          return Choice(list(value))
      elif (SUPPORTS_ENUM and isinstance(value, type)
              and issubclass(value, enum.Enum)):
          return Choice(value)
      elif isinstance(value, list):
          return OneOf(value)
      elif value is float:
          return Number()
      elif value is None:
          return Template()
      elif value is dict:
          return TypeTemplate(abc.Mapping)
      elif value is list:
          return TypeTemplate(abc.Sequence)
      elif isinstance(value, type):
          return TypeTemplate(value)
      else:
          raise ValueError(u'cannot convert to template: {0!r}'.format(value))
docs: Convert a simple "shorthand" Python value to a `Template`.