본문 바로가기

Programming/python35

python SSLerror "certificate verify failed: unable to get local issuer certificate" "ConnectionError: Couldn't reach '~~~~~' on the Hub (SSLError)" huggingface 쓰면서 조우한 error인데 huggingface에만 국한된건 아니고 urllib 나 requests 등 https 통신 할때 발생하는 SSLerror 이다. 내 환경은 우분투 였고 https://stackoverflow.com/questions/10667960/python-requests-throwing-sslerror 이곳 통해 해결 # debian os.environ['REQUESTS_CA_BUNDLE'] = os.path.join( '/etc/.. 2023. 10. 27.
간결한 python 문법을 쓰자 - lambda python 스러운 코드를 짜자 ex. flatten = lambda l: [item for sublist in l for item in sublist] #을 풀어서 쓰면 def flatten(l:list): a = [] for i in l: for j in i: a.append(j) return a 2022. 5. 9.
간결한 python 문법을 쓰자 - one line condition python 스러운 코드를 짜자 ex. dG ={} current_node = 1 default_p = 0.1 p = dG.get('p_val', default_p) if current_node in dG else default_p #이 한줄코드를 길게 짜면 if current_node in dG: if 'p_val' not in dG[current_node]: p = default_p else: p = dG[current_node]['pval'] else: p = default_p 코드가 짧아지면 좋지만 그건 가독성 & 명료성을 높이는 방향으로 짧아져야 한다. dictionary 의 get(key, default_value) one-line if condition은 가독성도 높이고 간결성도 높인다. 2022. 4. 12.
[vscode] 외부 모듈을 debug하고 싶을때 break을 찍어도 내가 짠 코드가 아닌 외부 코드는 break걸리지 않는다. launch.json 설정을 "program": "${file}", "console": "integratedTerminal", "justMyCode": false justMyCode을 False로 해주면 debug 할 수 있다. 2021. 11. 23.