Re: Printing dictionary values rather than references

2009-06-10 Thread Terry Reedy
Amit Dor-Shifer wrote: Hi all. I'd like to print-out a dictionary of objects. The printed values are references. How Do I print the actual objects. You can only print string representations, as defined by type(ob).__str__ and type(ob).__repr__. class MyClass: def __str__(self):

Re: Printing dictionary values rather than references

2009-06-10 Thread Jeff McNeil
On Jun 10, 10:19 am, Amit Dor-Shifer wrote: > Hi all. > > I'd like to print-out a dictionary of objects. The printed values are > references. How Do I print the actual objects. > > class MyClass: >     def __str__(self): >         return str(self.__dict__) > > if __name__ == '__main__': >     dict

Re: Printing dictionary values rather than references

2009-06-10 Thread Ben Charrow
Amit Dor-Shifer wrote: > Hi all. > > I'd like to print-out a dictionary of objects. The printed values are > references. How Do I print the actual objects. > > Thanks, > Amit How about this: class MyClass: def __str__(self): return str(self.__dict__) def __repr__(self):

Printing dictionary values rather than references

2009-06-10 Thread Amit Dor-Shifer
Hi all. I'd like to print-out a dictionary of objects. The printed values are references. How Do I print the actual objects. class MyClass: def __str__(self): return str(self.__dict__) if __name__ == '__main__': dict = dict() classA = MyClass() setattr(classA, "attr-1", "