#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "Q1mi"
# Date: 2017/9/17

"""
__repr__ VS __str__

参考链接：https://dbader.org/blog/python-repr-vs-str
"""


class Car(object):
    def __init__(self, brand, color):
        self.brand = brand
        self.color = color

    def __str__(self):
        return f"a {self.color} {self.brand} Car"

    def __repr__(self):
        return f"{self.__class__.__name__}({self.brand}, {self.color})"

c1 = Car("Audi", "red")
print(c1)


1ca3a1cbd583ef7989e77ba6fb70538b1027a87f
<mask token>


class Car(object):
    <mask token>

    def __str__(self):
        return f'a {self.color} {self.brand} Car'
    <mask token>


<mask token>

<mask token>


class Car(object):

    def __init__(self, brand, color):
        self.brand = brand
        self.color = color

    def __str__(self):
        return f'a {self.color} {self.brand} Car'
    <mask token>


<mask token>

<mask token>


class Car(object):

    def __init__(self, brand, color):
        self.brand = brand
        self.color = color

    def __str__(self):
        return f'a {self.color} {self.brand} Car'

    def __repr__(self):
        return f'{self.__class__.__name__}({self.brand}, {self.color})'


<mask token>

<mask token>


class Car(object):

    def __init__(self, brand, color):
        self.brand = brand
        self.color = color

    def __str__(self):
        return f'a {self.color} {self.brand} Car'

    def __repr__(self):
        return f'{self.__class__.__name__}({self.brand}, {self.color})'


<mask token>
print(c1)

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "Q1mi"
# Date: 2017/9/17

"""
__repr__ VS __str__

参考链接：https://dbader.org/blog/python-repr-vs-str
"""


class Car(object):
    def __init__(self, brand, color):
        self.brand = brand
        self.color = color

    def __str__(self):
        return f"a {self.color} {self.brand} Car"

    def __repr__(self):
        return f"{self.__class__.__name__}({self.brand}, {self.color})"

c1 = Car("Audi", "red")
print(c1)

