Issue
In python, is there a difference between repr
and the backquote `
(left of 1)?
For demonstration:
class A(object):
def __repr__(self):
return 'repr A'
def __str__(self):
return 'str A'
>>> a = A()
>>> repr(a)
#'repr A'
>>> `a`
#'repr A'
>>> str(a)
#'str A'
Do the backquotes just call repr
? Is it simply for convenience? Is there any significant speed difference?
Thanks!
Solution
They're an alias for repr
. They have the exact same effect.
However, they're deprecated and have been removed in Python 3. Don't use them; use repr
.
Answered By - agf
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.