Skip to content

Instantly share code, notes, and snippets.

@rollin96
Last active February 19, 2019 11:22
Show Gist options
  • Save rollin96/4b5de92a821f896877db6fa19d9067f4 to your computer and use it in GitHub Desktop.
Save rollin96/4b5de92a821f896877db6fa19d9067f4 to your computer and use it in GitHub Desktop.
jupyter 관련 gist
# python의 "param1"과 "param2" 변수를 bash 스크립트에서 각각 $1과 $2로 사용할 수 있게 해준다.
%%bash -s $param1 $param2
echo $1 $2
## debugging
* cheatsheet : https://appletree.or.kr/quick_reference_cards/Python/Python%20Debugger%20Cheatsheet.pdf
```
with open( base_dir + pred_filename, "r", encoding="utf-8") as f:
pred_data = f.read().split('\n')
import pdb; pdb.set_trace()
for idx, line in enumerate( pred_data ):
if len( line ) == 0:
break;
```
위와 같이 코드 중간에 넣어두면, 그 line에서 pdb prompt가 열린다.
n : next
변수명을 치면 바로 변수의 값을 볼 수도 있고, 실행도 된다.
# inline(!)으로 shell command를 호출할 경우 {param} 형태를 해준다.
```
message = "test123"
!echo {message}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment