w3resource

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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

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://198.211.115.131/python/built-in-function/repr.php