Python: repr() function
repr() function
The repr() function returns a string containing a printable representation of an object.
Version:
(Python 3.2.5)
Syntax:
repr(object)
Parameter:
Name | Description | Required / Optional |
---|---|---|
object | An object. | Required |
Return value:
A printable representational string of the given object.
Example: Python repr() function
class Example:
name = 'Bishop'
def __repr__(self):
return repr(self.name)
print(repr(Example()))
Output:
'Bishop'
Python Code Editor:
Previous: range()
Next: reversed()
Test your Python skills with w3resource's quiz
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/python/built-in-function/repr.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics