+ 1
What is the meaning of !r ?
def __repr__(self): return f'Car({self.color!r},{self.mileage!r})' can anyone tell me what is the meaning !r in this code why people use this in their codes.
1 Answer
+ 2
It tell to python to use the representation (by __repr__()) of corrispective parameter (in this case self.color and self.mileage) for put it in string instead of default string conversion
https://docs.python.org/3.1/library/string.html#format-string-syntax