Consider this code:
class Foo:
def geta(self):
self.a = 'lie'
return 'this is {self.a}'.format(?)
What should I write instead of the question mark so that the string will be formatted correctly?
What you probably are looking for is
'this is {0.a}'.format(self)
'this is {.a}'.format(self)
'this is {o.a}'.format(o=self)
'this is {self.a}'.format(self=self)
Note, however, that you are missing at least a method in your class.
Directly under the class scope there is no such thing as self.
{0.a} or similar. {.a} works only once. It fails otherwise like in: "'this is {.a}, i repeat myself {.a}'.format(self)'".this is {.a}, i repeat myself {.a}'.format(self, self), it works. The first self is for the first {.a}, the second one for the second one. As documented.The reference you include inside the brackets refers to either a number indicating the index of the argument passed to format, or a name directing to a named argument in the format call. Like that:
class Foo:
def geta(self):
self.a = 'lie'
return 'this is {self.a}'.format(self=self)
'this is {}'.format (self.a)