What is the difference between `__str__` and `__repr__` methods in Python?



What is the difference between `__str__` and `__repr__` methods in Python?..

Answer / nashiinformaticssolutions

`__str__` is used for creating a user-friendly string representation of an object. `__repr__` is used for creating a detailed string representation of an object, intended for debugging.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

Explain polymorphism in Python.

3 Answers  


What does [::-1} do?

0 Answers  


Is set iterable python?

0 Answers  


How do you sort in descending order in python?

0 Answers  


Why do we want to use break statement in while-loop?

0 Answers  






Why python has no private?

0 Answers  


How will you convert an integer to a hexadecimal string in python?

0 Answers  


Explain how to create a multidimensional list.

1 Answers  


How do you split a list into evenly sized chunks?

0 Answers  


What is for-else and while-else in python?

0 Answers  


What is a sequence in python?

0 Answers  


How will you differentiate between deep copy and shallow copy?

0 Answers  


Categories