https://docs.python.org/dev/faq/library.html#can-t-we-get-rid-of-the-global-interpreter-lock Library and Extension FAQ Contents: Library and Extension FAQ- General Library Questions- How do I find a module or application to perform task X?, Where is the math.py (socket.py, regex.py, etc.) source file?, How do I mak... docs.python.org GIL 때문에 완전한 multithread의 이점을 못누려서 IO Bound task들이나 C로 구현되어 있는 ..
import traceback try: ... except Exception as e: print(e) 코딩을 하다보면 발생하는 예외를 처리하기 위해 try except 문을 많이 쓰게된다. 근데, 위에 코드 처럼 구현하면 어떤 예외가 발생하는지는 알 수 있지만 어디서 어떤 작업을 하다가 해당 예외가 발생했는지 추적이 어렵다. 어디서 예외가 발생했는지 추적을 하기 위해서는 traceback을 import하고 traceback.print_exc()를 except 블럭에서 호출해주면 된다. import traceback try: ... except Exception as e: print(e) traceback.print_exc()
with open(...) as f: for(...): f.write(...) f.flush() 바로 flush()함수를 호출해주면된다. 이거 안해주면 쓰기 작업이 다 마친뒤에야 확인 가능하다. (logging 모듈써서 로깅하는 거면 중간에도 확인 가능) 파일에 쓸 게 많고 파일에 로그를 남기기 위해 소요되는 시간이 길다면 이게 잘 써지고는 있는지 불안하길 마련인데 적절한 시기에 flush 를 한 번씩 해주면 바로 logging이 어떻게 됐나 확인할 수 있다.
Python 프로그래밍중 프로그램이 키보드 인터럽트(Ctrl + c) 혹은 강제 종료, 정상 종료 케이스에 따라서 특정 함수가 호출됐어야 했었습니다. 제 경우를 자세히 말씀드리자면 pyav를 사용하여 RTSP 프로토콜로 비디오를 수신받아 디코딩을 하는데, RTSP 서버(VLC 이용)와 연결 후 연결을 끊어주지 않고 클라이언트 측 프로그램이 종료되는 경우 RTSP 서버의 VLC 프로그램 또한 정상적으로 동작을 안하는 문제가 있었습니다. 확인해보니 항상 연결을 끊어줘야하는데 그렇지 않은 경우 문제가 발생하던 것이였습니다. https://github.com/PyAV-Org/PyAV GitHub - PyAV-Org/PyAV: Pythonic bindings for FFmpeg's libraries. Python..
https://github.com/developer0hye/commitcleaner GitHub - developer0hye/commitcleaner: Clean your all commit history in one line Clean your all commit history in one line. Contribute to developer0hye/commitcleaner development by creating an account on GitHub. github.com 커밋 기록을 명령어 한줄로 싹 날려주는 패키지 pip install commitcleaner cd {your project} commitcleaner 커밋 기록 날리는 방법을 스택오버플로로 찾아 봤는데 명령어를 좀 여러줄 입력시켜줘..
windows 에서 rglob 을 통해 파일(*.ext)을 읽어들이면 파일 확장자에 insensitive해서 대문자 (*.EXT) 든 소문자(*.ext)든 알아서 잘 읽는다. linux 계열에서는 rglob을 통해 파일을 읽어들일때는 파일 확장자에 sensitive 하다. 그래서, 대문자, 소문자 둘다 읽어들이려면 별도의 후처리가 필요하다. 삽질을 안하려면 대문자, 소문자를 통일 시켜줄 필요가 있다. 아 근데 이건 rglob 에 국한된 건 아니고 glob.glob 도 마찬가지 일거 같고, 여타 파일 읽기/쓰기가 필요한 모든 코드에 적용되는 사항같다. https://superuser.com/questions/862270/convention-for-file-extensions-uppercase-or-lowe..
https://stackoverflow.com/a/53877507 Python progress bar and downloads I have a Python script that launches a URL that is a downloadable file. Is there some way to have Python display the download progress as oppose to launching the browser? stackoverflow.com import urllib.request from tqdm import tqdm class DownloadProgressBar(tqdm): def update_to(self, b=1, bsize=1, tsize=None): if tsize is no..
https://stackoverflow.com/questions/3211041/how-to-join-two-generators-or-other-iterables-in-python How to join two generators (or other iterables) in Python? I want to change the following code for directory, dirs, files in os.walk(directory_1): do_something() for directory, dirs, files in os.walk(directory_2): do_something() to this code: for stackoverflow.com Python Generator는 '+' 연산을 지원하지 않는..
conda search python 입력하면 conda 환경 구축시 설정가능한 python 버전이 출력된다. 23년 4월 23일자 기준 3.11 이 출력됨을 확인했다. (base) PS C:\Users\yonghye\Documents\Workspace\detr> conda search python Loading channels: done # Name Version Build Channel python 2.7.13 h1b6d89f_16 pkgs/main python 2.7.13 h9912b81_15 pkgs/main python 2.7.13 hb034564_12 pkgs/main python 2.7.14 h2765ee6_18 pkgs/main python 2.7.14 h3e68818_15 pkgs/main..
나는 안되더라 try: cv2.imread(file) except: pass try 내에서 명시적으로 raise 해주지 않는 이상 cv2.imread 내부에서 발생하는 예외는 except문에 안걸렸다. stack overflow에서 하라는 방법대로 해도 안걸림... https://github.com/ultralytics/ultralytics/pull/2103 Support Multilanguage for imread and imwrite by developer0hye · Pull Request #2103 · ultralytics/ultralytics copilot:all github.com 원래 try except 구문으로 구현하려했는데 except 문에 안걸려서 그냥 아래처럼 구현해서 PR날림... f..
- Total
- Today
- Yesterday
- LCA
- MOT
- ㅂ
- 인공지능을 위한 선형대수
- 백준
- 위상 정렬 알고리즘
- 백준 1766
- 조합
- 순열
- 이분탐색
- 단축키
- 파이참
- 가장 긴 증가하는 부분 수열
- FairMOT
- PyCharm
- Lowest Common Ancestor
- 백준 11053
- 문제집
- 백준 11437
- cosine
- C++ Deploy
- 자료구조
- 백트래킹
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |