Programming/python(파이썬)
python py_compile 모듈을 이용한 문법 검사
구차니
2026. 7. 7. 11:18
인터프리트 언어 특성상 해보기 전에 오타나 이런걸 확인하기 좀 어려운데
py를 pyc pyo등으로 바꾸는 "컴파일"을 제공하는 언어다 보니
python byte code로 변환하기 위해 문법을 체크하는지
이걸 이용해서 문법을 우회적으로(?) 확인할 수 있다
| $ pycompile Usage: pycompile [-V [X.Y][-][A.B]] DIR_OR_FILE [-X REGEXPR] pycompile -p PACKAGE |
오.. 좋은데?
| $ cat tt.py mport time time.sleep(1) $ pycompile tt.py File "tt.py", line 1 mport time ^ SyntaxError: invalid syntax |
[링크 : https://salguworld.tistory.com/entry/LinuxPython-파이썬-pycompile-활용-파이썬-코드-C-코드-컴파일-예제-1단일-소스코드-컴파일]
[링크 : https://stackoverflow.com/questions/4537411/compile-but-do-not-run-a-python-script]
thank you claude.ai