Author: dreiss
Date: Mon Jan  5 12:14:52 2009
New Revision: 731685

URL: http://svn.apache.org/viewvc?rev=731685&view=rev
Log:
THRIFT-241. python: Generate a better implementation of __repr__

Modified:
    incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc?rev=731685&r1=731684&r2=731685&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc 
(original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc Mon Jan  
5 12:14:52 2009
@@ -614,11 +614,10 @@
   // Printing utilities so that on the command line thrift
   // structs look pretty like dictionaries
   out <<
-    indent() << "def __str__(self):" << endl <<
-    indent() << "  return str(self.__dict__)" << endl <<
-    endl <<
     indent() << "def __repr__(self):" << endl <<
-    indent() << "  return repr(self.__dict__)" << endl <<
+    indent() << "  L = ['%s=%r' % (key, value)" << endl <<
+    indent() << "    for key, value in self.__dict__.iteritems()]" << endl <<
+    indent() << "  return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" 
<< endl <<
     endl;
 
   // Equality and inequality methods that compare by value


Reply via email to