Skip to content

Instantly share code, notes, and snippets.

@ryan-williams

ryan-williams/a_b.ipynb Secret

Last active Jun 8, 2020
Embed
What would you like to do?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env bash
# Convert various notebook-based import tests to Python (to additionally test that they work there)
set -e
for style in abs; do
for type in py nb; do
name="${style}_${type}"
nb="nb_${name}.ipynb"
py="py_${name}.py"
jupyter nbconvert "$nb" --to python --stdout | \
perl -pe 's/def nb_/def py_/' \
> "$py"
done
done
def ddd(): return 'DDD!'
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python
# coding: utf-8
# Import from a notebook:
# In[ ]:
import ur
from a_b import a, b
def py_abs_nb(): return a() + b()
#!/usr/bin/env python
# coding: utf-8
# Import from a Python file:
# In[ ]:
import ur
from d import ddd
def py_abs_py(): return ddd() + 'yay'
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment