Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16682 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2011-12-05 14:55 -0500 |
| Last post | 2011-12-05 14:55 -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: Fwd: class print method... Terry Reedy <tjreedy@udel.edu> - 2011-12-05 14:55 -0500
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-12-05 14:55 -0500 |
| Subject | Re: Fwd: class print method... |
| Message-ID | <mailman.3317.1323114924.27778.python-list@python.org> |
On 12/5/2011 8:09 AM, Dave Angel wrote:
> useful, such as if you print a list. The __str__() method of list calls
> the __repr__() for each object inside it. So it can be useful to define
> both, even if you decide to have them do the same thing.
If you want __str__ and __repr__ to do the same thing, you only need
*one* def statement and an assignment.
def __str__(self): <whatever>
__repr__ = __str__
--
Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web