Why use backticks?

Daniel Fackrell unlearned at DELETETHIS.learn2think.org
Wed May 7 10:00:26 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...
> > I was showing a friend around Python using the Shell. He asked for a
> few
> > Python equivalents of common Perl and VB constructs. The use of
> > backticks come up. After showing the use of os.popen I demonstrated
> >
> >   out = `ls`
> >
> > but to my surprise it didn't generate the expected SyntaxError but
> > rather a NameError. So after some Googling I found that backticks
> around
> > an expression ( `expression`) are equivalent to calling
> > repr(expression). Every day a learning moment.
> >
> > 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.


Maybe at least worth deprecating?  I'm not aware of any policy declaring
that deprecated features disappear in any given amount of time, but if a
time came when it was felt that removing `` would be good, it might be
better to have had it already deprecated for a while.

--
Daniel Fackrell (newsgroups.NOSPAM at dfackrell.mailshell.com)
When we attempt the impossible, we can experience true growth.






More information about the Python-list mailing list