repr vs. str


import datetime

Create A Simple Object

class Regiment(object):

    def __init__(self, = date

    def __repr__(self):
        return date

    def __str__(self):
        return str(date)

__repr__ is for the developer. It is string representation of the object and the code needed to reproduce the object.

__str__ is the output for the end user. It prints what the user wants to see.