Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16641 > unrolled thread
| Started by | Dave Angel <d@davea.name> |
|---|---|
| First post | 2011-12-05 02:48 -0500 |
| Last post | 2011-12-05 02:48 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: class print method... Dave Angel <d@davea.name> - 2011-12-05 02:48 -0500
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2011-12-05 02:48 -0500 |
| Subject | Re: class print method... |
| Message-ID | <mailman.3289.1323071369.27778.python-list@python.org> |
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
Back to top | Article view | comp.lang.python
csiph-web