Is there a way to access variables in the current python kernel from within a %%bash
or other %%script
cell?
Perhaps as command line argume
To include python variables within bash commands run using the syntax !
you can use {
as follows:
In [1]: for i in range(3):
...: !echo {i+1}
...:
1
2
3
While this is slightly different from what the OP asked, it is closely related and useful in performing a scripting task. This post has more great tips and examples of using shell command within IPython and Jupyter notebooks.