Skip to main content

Jupyter-like cell running in ipython

Project description

ipython-cells

IPython extension for executing cells Jupyter-style in .py files. Supports Jupyter and Spyder cell syntax.

Brings the advantages of linear, selective-execution during development to IPython without the bloat of Jupyter.

Example

We can execute the invidual cells in a .py file just like a Jupyter notebook.

example.py

# %% cell1
a = 10
print(a)

# %% cell2
a += 1
print(a)

In IPython:

# load the extension and a .py file
%load_ext ipython_cells
%load_file example.py

# run some cells
%cell_run cell1
10
%cell_run cell2
11

# list available cells for running
%list_cells
['__first', 'cell1', 'cell2']

Installation

pip install ipython-cells

Optionally, automatically load ipython-cells when IPython starts

~/.ipython/profile_default/ipython_config.py

c.InteractiveShellApp.extensions = [
    'ipython_cells'
]

Execute a range of cells

%load_file example.py

# run all cells from beginning of file to cell2 (inclusive)
%cell_run ^cell2
10
11

# run all cells from cell1 (inclusive) to end of file
%cell_run cell1$
12
13

Autoreloading

# load example.py with autoreloading
%load_file example.py --autoreload

%cell_run cell1
10
# example.py is modified by an external editor (e.g. `a = 10`  ->  `a = 20`)
# File change is detected and automatically reloaded
%cell_run cell1
20

Cell Delimiter Syntax

Cells are delimited by special comments. Both Jupyter and Spyder style cells are supported.

Examples

  • # %% foobar_cell
  • # In[foobar_cell]
  • # %% foobar_cell some extra text
  • # In[foobar_cell] some extra text

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipython_cells-4.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

ipython_cells-4-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file ipython_cells-4.tar.gz.

File metadata

  • Download URL: ipython_cells-4.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8

File hashes

Hashes for ipython_cells-4.tar.gz
Algorithm Hash digest
SHA256 3a220dc75c110026658c1305ff4c8e098e407c14d7a1db7b25bc2cac4de4fae0
MD5 0bf4da785ffd07284f11260da68ab19f
BLAKE2b-256 7e68e402a52effc24f282b7fd0dc40287d2ccc369afec6e688d820e74af8b767

See more details on using hashes here.

File details

Details for the file ipython_cells-4-py3-none-any.whl.

File metadata

  • Download URL: ipython_cells-4-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8

File hashes

Hashes for ipython_cells-4-py3-none-any.whl
Algorithm Hash digest
SHA256 b4b739770e99bf73d1d150c8f4464ec99798b8033129637f5a431b6a74da9703
MD5 e1d4455621931c41f4aa7cab47bc4c14
BLAKE2b-256 acc2f0346934face1d0c814c96c0126453ecb0b84a57d7b0ad3f206dc9d319a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page