Why use backticks?

Skip Montanaro skip at pobox.com
Thu May 8 06:48:39 EDT 2003


    Francis> Of course, maybe we should just use 'x = %s' % 1.  But anyway,
    Francis> I see backticks a lot, and I use them quite a bit, too.  Are
    Francis> they really slated for removal?

I don't believe they are removal candidates, at least not until Python 3.
In any case, they are too widely used to remove during the 2.x series, and
they are convenient to use during interactive sessions when you want to see
the precise content of strings.  "Discouraged" might be a more apt
description of their status.

    Francis> Seems kinda drastic.  I for one never got them confused with
    Francis> the shell syntax, and I'd be sad to see them go. Surely
    Francis> converting a value to a string is a common enough operation to
    Francis> deserve its own terse special syntax?

The confusion isn't with the shell syntax, it's do they mean str() or
repr()?  If repr() deserves a shortcut syntax, why not str()?  Finally,
backticks are very small, easily hidden, bits of punctuation which can
fairly easily be overlooked or confused with single quotes.

Skip





More information about the Python-list mailing list