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



Follow us on Facebook and Twitter for latest update.