파이썬에서 repr
과 backquote `
(왼쪽에서 1) 사이에 차이점이 있습니까? 데모Python : repr vs backquote
:
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'
역 인용 부호는 repr
를 호출합니까? 단순히 편의를 위해서입니까? 어떤 중요한 속도 차이가 있습니까?
감사합니다.
중복 된 http://stackoverflow.com/questions/1673071/what-do-backticks-mean-to-the-python-interpreter-num? – AlG
왜 속도 차이에 대해 걱정 하시겠습니까? –
@NedBatchelder, 대부분 호기심. – TorelTwiddler