파이썬[Python]: 내장함수 - __qualname__ 변수
내장함수 - __qualname__ 변수(variable)
/// 설명
클래스, 함수(메서드)의 이름을 표현합니다. 함수(메서드)일 경우 클래스의 이름을 같이 명시합니다. A Variable in Python Standard
※ 형식
__qualname__
reference
https://docs.python.org/3/library/inspect.html
https://www.python.org/dev/peps/pep-3155/
※ 형식
__qualname__
reference
https://docs.python.org/3/library/inspect.html
https://www.python.org/dev/peps/pep-3155/
/// 예제
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import sys print(int.__name__) # int print(int.__qualname__) # int print(breakpoint.__name__) # breakpoint print(breakpoint.__qualname__) # breakpoint print(int.bit_length.__name__) # bit_length print(int.bit_length.__qualname__) # int.bit_length class MyClass: print('in class: ', __name__) # in class: __main__ print('in class: ', __qualname__) # in class: MyClass def my_method(self): print('in method: ', __name__) # print('in method: ', __qualname__) # Error print(MyClass.__name__) # MyClass print(MyClass.__qualname__) # MyClass print(MyClass.my_method.__name__) # my_method print(MyClass.my_method.__qualname__) # MyClass.my_method test = MyClass() print(test.my_method()) # in method: __main__ def my_function(): print('in function: ', __name__) # print('in function: ', __qualname__) # Error print(my_function.__name__) # my_function print(my_function()) # in function: __main__ # int.__qualname__ = 'int.__qualname__' # Error # breakpoint.__qualname__ = 'breakpoint.__qualname__' # Error # int.bit_length.__qualname__ = 'int.bit_length.__qualname__' # Error # it may be changed __qualname__ = '__qualname__' print(__qualname__) | cs |
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기