def _format_object(object):
attrs = iter(object.__dict__.items())<EOL>if object.__class__:<EOL><INDENT>attrs = chain(attrs, iter(object.__class__.__dict__.items()))<EOL><DEDENT>is_model = isinstance(object, Model)<EOL>is_form = isinstance(object, BaseForm)<EOL>attrs = dict(<EOL>(k, v)<EOL>for k, v in attrs<EOL>if not k.startswith('<STR_LIT:_>')<EOL>and not getattr(v, '<STR_LIT>', False)<EOL>and not (is_model and k in ('<STR_LIT>', '<STR_LIT>'))<EOL>and not (is_form and k in ('<STR_LIT:Meta>',))<EOL>)<EOL>for member in dir(object):<EOL><INDENT>try:<EOL><INDENT>if member.startswith('<STR_LIT:_>') or not hasattr(object, member):<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except HANDLED_EXCEPTIONS as e:<EOL><INDENT>attrs[member] = _format_exception(e)<EOL>continue<EOL><DEDENT>value = getattr(object, member)<EOL>if callable(value) or member in attrs or getattr(value, '<STR_LIT>', False):<EOL><INDENT>continue<EOL><DEDENT>attrs[member] = value<EOL><DEDENT>for name, value in list(attrs.items()):  <EOL><INDENT>if isinstance(value, property):<EOL><INDENT>attrs[name] = _try_call(lambda: getattr(object, name))<EOL><DEDENT>elif isinstance(value, types.FunctionType):<EOL><INDENT>if PY3:<EOL><INDENT>spec = inspect.getfullargspec(value)<EOL><DEDENT>else:<EOL><INDENT>spec = inspect.getargspec(value)<EOL><DEDENT>if len(spec.args) == <NUM_LIT:1> or len(spec.args) == len(spec.defaults or ()) + <NUM_LIT:1>:<EOL><INDENT>if _is_unsafe_name(name):<EOL><INDENT>attrs[name] = LiteralStr('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>attrs[name] = _try_call(lambda: value(object))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>del attrs[name]<EOL><DEDENT><DEDENT>elif hasattr(value, '<STR_LIT>'):<EOL><INDENT>attrs[name] = value = _try_call(lambda: getattr(object, name), return_exceptions=True)<EOL>if isinstance(value, Manager):<EOL><INDENT>attrs[name] = LiteralStr('<STR_LIT>'.format(value.__class__.__name__))<EOL><DEDENT>elif isinstance(value, AttributeError):<EOL><INDENT>del attrs[name]  <EOL><DEDENT>elif isinstance(value, HANDLED_EXCEPTIONS):<EOL><INDENT>attrs[name] = _format_exception(value)<EOL><DEDENT><DEDENT><DEDENT>if getattr(object, '<STR_LIT>', None) is not object.__str__:<EOL><INDENT>attrs['<STR_LIT>'] = _try_call(lambda: smart_str(object))<EOL><DEDENT>elif getattr(object, '<STR_LIT>', None) is not object.__unicode__:<EOL><INDENT>attrs['<STR_LIT>'] = _try_call(lambda: smart_str(object))<EOL><DEDENT>if hasattr(object, '<STR_LIT>'):<EOL><INDENT>attrs['<STR_LIT>'] = LiteralStr('<STR_LIT>')<EOL><DEDENT>if hasattr(object, '<STR_LIT>'):<EOL><INDENT>attrs['<STR_LIT>'] = LiteralStr('<STR_LIT>')<EOL><DEDENT>if hasattr(object, '<STR_LIT>'):<EOL><INDENT>attrs['<STR_LIT>'] = LiteralStr('<STR_LIT>')<EOL><DEDENT>if hasattr(object, '<STR_LIT>'):<EOL><INDENT>attrs['<STR_LIT>'] = len(object)<EOL><DEDENT>if isinstance(object, BaseForm):<EOL><INDENT>for field_name in list(object.fields.keys()):<EOL><INDENT>attrs[field_name] = object[field_name]<EOL><DEDENT>del attrs['<STR_LIT>']<EOL><DEDENT>return _format_dict(attrs)<EOL>
# Instead of just printing <SomeType at 0xfoobar>, expand the fields.