A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/081525.html below:

bug? __repr__ vs. __str__

bug? __repr__ vs. __str__ bug? __repr__ vs. __str__Aahz Maruch aahz at panix.com
Fri Apr 20 19:58:42 EDT 2001
In article <20010420.154310.1501252996.615 at mead.troikanetworks.com>,
Bruce Edge <bedge at troikanetworks.com> wrote:
>Does this seem broken to anyone else?
>
>>>> class T:
>...   def __repr__(self):
>...     return "repr"
>...   def __str__(self):
>...     return "str"
>... 
>
>>>> t =T()
>>>> str(t)
>'str'
>
>>>> l=[t,t,t,t]
>>>> str(l)
>'[repr, repr, repr, repr]'

Nope: lists pass down repr() to their objects
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het Pythonista   http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Beware of companies that claim to be like a family.  They might not be
lying."  --Jill Lundquist

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4