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):
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
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):
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", "