On 12/05/2011 02:11 AM, Suresh Sharma wrote:
Hello All,
I am new to python and i have stuck up on a particular issue with classes,
i understand this might be a very dumb question but please help me out.

I have created two classes and whenever i try to print the objects i get
this message but not the data,  __main__.cards instance at ****(memory
location) i even tried using __str__ but calling it also produces the same
result. Can anyone please help me how to get my objects printed. I googled
a lot but could not find anything relevant.

thanks in advance

regards
suresh

You were close, but you have it backward. You don't call __str__() to print an object, you implement __str__() in your object.

If you write a class without also writing __str__(), then print won't know what to do with it.

--

DaveA

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to