util.py 472 B

123456789
  1. def _repr(node, args=None, nameblacklist=None):
  2. classname = node.__class__.__name__
  3. args = args or []
  4. nameblacklist = nameblacklist or []
  5. for key, value in filter(lambda item: not item[0].startswith("_") and item[0] not in nameblacklist,
  6. sorted(node.__dict__.items(),
  7. key=lambda item: item[0])):
  8. args.append("%s=%r" % (key, value))
  9. return "%s(%s)" % (classname, ", ".join(args))