[Python-Dev] Re: PendingDeprecationWarning

Guido van Rossum guido@python.org
Wed, 29 May 2002 15:42:08 -0400


> Having both repr AND the peculiar `...` operator is another one of
> those things which I find _really_ hard to explain without
> handwaving and without sounding negative about Python, a language
> about which I'm actually enthusiastic.

Give yourself a bit of credit, Alex.  Surely you can talk
marketing-speak if you want to!

FWIW, I consider `...` a historic wart and a failed experiment (even
though I use it frequently myself).  It appeared in a different form
in ABC, where you could use `...` inside a string literal to do
variable substitution (expression substitution actually).  I think I
found it to hard to implement that in the parser, so I decided that
`...` would be a separate construct that you could embed in a string
using regular string concatenation.  But that means that the
equivalent of "The sum of $a and $b is $c" would have to be written as

  "The sum of " + `a` + " and " + `b` + " is " + `c`

which contains way too much interpunction.  The other killer is that
it uses repr() rather than str().  Python 0.0 only had `...`, it had
neither str() not repr().

> I'd rather lose the `...`
> (via pendingsilentdeprecation or whatever).

+0

> As to repr itself, I'd be +0 on taking it out of the builtins, but
> that's hardly a major issue, nor of course a realistic prospect.

Why get rid of repr()?  It's very useful.  In error messages I often
want to show an object relevant to the message, but if that object is
(or may be) a string, I don't want newlines and other control
characters in the string to mess up the formatting of the error
message.  repr() is perfect for that.

> str is obviously quite a different kettle of fish -- it's a TYPE and
> thus it cannot be substituted by whatever operator.  It would also
> be the natural way to put a format-with-whatever-number-base
> functionality (2-arg str, just like parsing with arbitrary base is
> 2-arg int -- perfect!).

How useful is formatting numbers with arbitrary bases?  I think
decimal and hex cover all current use cases; even octal is mostly
historic.  (I still read octal more quickly than hex, but that's
showing my age more than anything else -- I grew up around a CDC
mainframe that dumped in octal.)

--Guido van Rossum (home page: http://www.python.org/~guido/)