# representation must generate a string which uniquely identify an object
# a common pattern to use is to print content necessary to recreate the same object. That includes Object class name
# and attributes
# We can say that repr() is for developers and str() is for clients
# Logging and debuging should rely on repr(), because it will have much more information about the object than str()


class Point2D:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __str__(self):
        return '{point.x}, {point.y}'.format(point=self)

    def __repr__(self):
        return 'Point2D(x={}, y={})'.format(self.x, self.y)


if __name__ == '__main__':
    point = Point2D(x=10, y=20)
    print(str(point))
    print(repr(point))

    # Note that if we copy the string generated by repr and past it into this module (without the '), we'll have
    # a valid constructor. This is a common pattern of how repr can be implemented
    # If not implemented, both str and repr prints the class name plus instance id
    # for instance: <__main__.Point2D object at 0x7fe1d0ea4b00>
    