Why use backticks?

Francis Avila francisgavila at yahoo.com
Wed May 7 23:33:29 EDT 2003


"John Roth" <johnroth at ameritech.net> wrote in message
news:vbhn7hqa93aj2e at news.supernews.com...
>
> "Iwan van der Kleyn" <none at none.com> wrote in message
> news:3eb81743$0$123$e4fe514c at dreader4.news.xs4all.nl...
> > But why this rather obscure use of backticks? Is there any use for
> them
> > except making code harder to read ? :-)

> I believe they are a hangover from very early versions of Python,
> and have not been removed because there's not enough benefit
> for the hassle.

In my experience they are used mostly in pasting together strings, where
they remove a lot of verbosity and look somewhat more natural. Compare:

'x = '+`x`.
'x = ' + str/repr(x)

Of course, maybe we should just use 'x = %s' % 1.  But anyway, I see
backticks a lot, and I use them quite a bit, too.  Are they really slated
for removal?  Seems kinda drastic.  I for one never got them confused with
the shell syntax, and I'd be sad to see them go. Surely converting a value
to a string is a common enough operation to deserve its own terse special
syntax?
--
Francis Avila





More information about the Python-list mailing list