gives a printable representation of an object.
For some types(including strings), it's something that can be given to eval()
to create the object.
But this is not required, and classes can make it return any string.
So basically, just the first sentence there is really important.eval()
takes a string and evaluates it as if it was python code, and returns the result.
- Code: Select all
>>> eval('5 + min(1, 2)')
But using eval() in real code is not recommended, since it's a security risk - it allows execution of any python expressions.