Commits

Anonymous committed 1b5ccd7

improving text representation of Namespace objects

  • Participants
  • Parent commits cd03db4

Comments (0)

Files changed (2)

File pypeg2/__init__.py

 
     def __repr__(self):
         """x.__repr__() <==> repr(x)"""
-        result = type(self).__name__ + repr(tuple(self.data))
+        result = type(self).__name__ + "(["
+        for key, value in self.data.items():
+            result += "(" + repr(key) + ", " + repr(value) + ")"
+            result += ", "
+        result += "]"
         try:
             result += ", name=" + repr(self.name)
         except:

File samples/sample1.py

 Parameters.
 
 >>> f.parms
-Parameters([(Symbol(...'a'), <__main__.Parameter object at 0x...>), (Symbol(...'b'), <__main__.Parameter object at 0x...>)])
+Parameters([(Symbol(...'a'), <__main__.Parameter object at 0x...>), (Symbol(...'b'), <__main__.Parameter object at 0x...>), ])
 
 Because Parameters is a Namespace, we can access its content by name.