Backticks: What up?

donald.welch at hp.com donald.welch at hp.com
Tue Apr 27 20:04:32 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.
> 
> TIA.

I think `self.data` is equivalent to repr(self.data).

-Don




More information about the Python-list mailing list