Dave / Ryan<div>Thanks i have got it and it worked after using repr statement. Thanks everyone for their valuable feedback.</div><div><br></div><div><br><br><div class="gmail_quote">On Mon, Dec 5, 2011 at 6:11 PM, Lie Ryan <span dir="ltr"><<a href="mailto:lie.1296@gmail.com">lie.1296@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 12/05/2011 10:18 PM, Suresh Sharma wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
Pls help its really frustrating<br>
---------- Forwarded message ----------<br>
From: Suresh Sharma<br>
Date: Monday, December 5, 2011<br>
Subject: class print method...<br></div><div class="im">
To: "<a href="mailto:d@davea.name" target="_blank">d@davea.name</a> <mailto:<a href="mailto:d@davea.name" target="_blank">d@davea.name</a>>" <<a href="mailto:d@davea.name" target="_blank">d@davea.name</a><br>

<mailto:<a href="mailto:d@davea.name" target="_blank">d@davea.name</a>>><br>
<br>
<br>
Dave,<br>
Thanx for the quick response, i am sorry that i did not explain<br>
correctly look at the code below inspite of this i am just getting class<br>
object at memory location.I am sort i typed all this code on my android<br>
in a hurry so.indentation could.not.be.managed but this.similar code<br>
when i run all my objects created by class deck are not shown but stored<br>
in varioia meory locations. How can i display them.<br>
<br>
</div></blockquote>
<br>
I think you're in the right track, however I suspect you're running the code in the shell instead of as a script. The shell uses __repr__() to print objects instead of __str__(), so you either need to use 'print' or you need to call str(), note the following:<br>

<br>
Python 2.7.2+ (default, Oct  4 2011, 20:06:09)<br>
[GCC 4.6.1] on linux2<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> suits = ['spades', 'clubs', 'diamonds', 'hearts']<br>
>>> ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']<br>
>>> class Card:<br>
...     def __init__(self, rank, suit):<br>
...         self.suit = suit<br>
...         self.rank = rank<br>
...     def __str__(self):<br>
...         return suits[self.suit] + ' ' + ranks[self.rank]<br>
...<br>
>>> Card(2, 3) #1<br>
<__main__.Card instance at 0x7f719c3a20e0><br>
>>> str(Card(2, 3)) #2 of your<br>
'hearts 3'<br>
>>> print Card(2, 3) #3<br>
hearts 3<br>
<br>
In #1, the output is the __repr__() of your Card class; you can modify this output by overriding the __repr__() on your Card class.<br>
<br>
In #2, the output is the __repr__() of a string, the string is the return value from __str__() of your Card class. The repr of a string is the string enclosed in quotes, which is why there is an extra pair of quotes.<br>

<br>
In #3, you're 'print'-ing a string, the string is the return value from __str__() of your Card class. There's no extra quotes, since 'print' prints the string itself, not the repr of the string.<span class="HOEnZb"><font color="#888888"><br>

<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Suresh Sharma<br>Regional Project Manager,<br>O2F,Mumbai<div>Maharashtra-400101.<br> <br><br></div><br>
</div>