Backticks: What up?

Peter Hansen peter at engcorp.com
Wed Apr 28 09:07:20 EDT 2004


Steven Brent wrote:

> I was wondering why the backticks in the following fragment:
> 
>         return 'Here's the result: ' + `self.data`
> 
> My guess is that in a return statement (as opposed to a print statement)
> it's necessary to do this in order to get the self.data instance attribute
> as a string, so it can be concatenated with the 'Here's the result: '
> string.
> 
> What exactly do the backticks do, then? Just return the result of an
> expression as a string? Does my guess make sense and / or is it correct?
> Elucidations and gentle ridicule welcome.

I was looking for the proper language ref but sometimes they
can be hard to track down:

   http://docs.python.org/ref/string-conversions.html

-Peter



More information about the Python-list mailing list