Python 3.12(23.10.02) 오류 메시지 개선
2023. 12. 30. 13:12ㆍ개발 문서/Python
728x90
반응형
변경사항
1. 향상된 오류 메시지
1.1
>>> sys.version_info
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sys' is not defined. Did you forget to import 'sys'?
- NameError이제 표준 라이브러리의 모듈은 a가 최상위 레벨로 올라갈 때 인터프리터가 표시하는 오류 메시지의 일부로 잠재적으로 제안됩니다 .
1.2
class A:
def __init__(self):
self.blech = 1
def foo(self):
somethin = blech
>>> A().foo()
Traceback (most recent call last):
File "<stdin>", line 1
somethin = blech
^^^^^
NameError: name 'blech' is not defined. Did you mean: 'self.blech'?
- 인스턴스 예외 에 대한 오류 제안을 개선합니다
- 이제 NameError메서드에서 a 가 발생하고 인스턴스에 예외의 이름과 정확히 동일한 속성이 있는 경우 self.
1.3
>>> import a.y.z from b.y.z
Traceback (most recent call last):
File "<stdin>", line 1
import a.y.z from b.y.z
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Did you mean to use 'from ... import ...' instead?
- SyntaxError 오류 메시지 개선
- import x from y # 정상
- import y from x # 오류
1.4
>>> from collections import chainmap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'chainmap' from 'collections'. Did you mean: 'ChainMap'?
- ImportError 오류 메시지 개선
'개발 문서 > Python' 카테고리의 다른 글
Python으로 이메일 자동 전송하기 (0) | 2025.03.12 |
---|---|
Python으로 POP3를 이용한 메일 서버 연결과 활용 (0) | 2024.02.17 |
파이썬의 얕은 복사 (Shallow Copy) 깊은 복사 (Deep Copy) (0) | 2023.11.14 |
클러스터링 (K-Means, DBSCAN) (0) | 2023.11.09 |
결정 트리와 랜덤 포레스트 (0) | 2023.11.09 |