[Python-ideas] Reviving PEP 3140 - "str(container) should call str(item), not repr(item)"

Mark Janssen dreamingforward at gmail.com
Fri Apr 5 05:08:04 CEST 2013


> Having str(container) calling str(item) and not repr(item) sounds like the
> right thing to do. However, PEP 3140 was rejected on the basis of the
> following statement of Guido:

Strangely, this argument seems to get to a issue found in LISP
regarding quoting a thing vs. the thing itself.  Python doesn't
recognize really that distinction in its object model -- though it
does have a way to go the *other* direction:  type(thing).

I think Guido's intuition is correct -- there is no logically
"correct" way to do this.   The issue makes me think of a
__deepstr__() method or something that one could implement if one
wanted to print the contents of a container, but this doesn't really
work well either.

This is a problem with "everything is an object" model:  no
recognition is made between a distinction that is very high up the
"object taxonomy":  container vs. atomic elements.

FWIW,

MarkJ
Tacoma, Wash



More information about the Python-ideas mailing list