__repr__() Method

PHOTO EMBED

Sat Jun 22 2024 18:31:41 GMT+0000 (Coordinated Universal Time)

Saved by @pynerds #python

#Example with list
L = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(ascii(L.__repr__())) #same as print(L)

#Example with tuples
T = ("Pynerds", "Python", "Django", "Flask")
print(T.__repr__()) #same as print(T)

D = {1: "One", 2: "Two", 3: "Three"}

print(D.__repr__())#Same as print(D)
content_copyCOPY

https://www.pynerds.com/python-classes-repr-method/