a= [1,2,3,4]
b= 'sample string'
#Both will give the same output
print(str(a))
print(repr(a))
print(str(b))
print(repr(b))
import datetime
import pytz
a=datetime.datetime(2015, 6, 11, 4, 35, 48, 528521, tzinfo=pytz.UTC)
b='2015-06-11 04:35:48.528521+00:00'
#on surface both variables a and b looks same.
print(str(a))
print(str(b))
#The goal of __str__ is to be readable.
#whenever we ran repr(a) we are able to get it's a datetime.
print(repr(a))
print(repr(b))
#The goal of __repr__ is to be unambiguous.
a= datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
b=str(a)
#Another example
print('str(a): {}'.format(str(a)))
print('str(b): {}'.format(str(b)))
print()
print('repr(a): {}'.format(repr(a)))
print('repr(b): {}'.format(repr(b)))