Skip to content

Instantly share code, notes, and snippets.

@ryan-williams
Last active June 8, 2020 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan-williams/1288bff2f9e05394a94312010da267bb to your computer and use it in GitHub Desktop.
Save ryan-williams/1288bff2f9e05394a94312010da267bb to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"def a():\n",
" return 'aaa'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def b():\n",
" return 'bbb'"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ur-3.7.4",
"language": "python",
"name": "ur-3.7.4"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Display the source blob
Display the rendered blob
Raw
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!'
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
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'
Display the source blob
Display the rendered blob
Raw
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