Is it possible to split a Jupyter cell across cells when it contains a function, loop, or other block?(当 Jupyter 单元包含函数、循环或其他块时,是否可以跨单元拆分它?)
问题描述
Jupyter 具有一次执行一个单元格的功能.如果一个单元格有很多语句,则通常可以(希望)将其拆分为更小的单个语句单元格,除非涉及块,例如 if、for、def 等.
之前有人以不同的方式提出了这个问题:
Jupyter has a feature in being able to execute one cell at a time. If a cell has a lot of statements it's often possible (desirable) to split it into smaller single statement cells, except when a block is involved,e.g if, for, def, etc.
this question was asked earlier in a different way:
Execute algorithm step by step in Jupyter
and answered
What is the right way to debug in iPython notebook?
While invoking a debugger may be the best option available, it does seem kludgy, and it likely would not work with non Python kernels.
What would be ideal is to have nested cells, and have a way to execute the entire block or the subcell.
for a Python example splitting a cell containing:
if 0 == 1:
zero = 1
else:
zero = 0
into, say, two cells:
if 0 == 1:
zero = 1
and
else:
zero = 0
likewise for Julia or R.
a debugger solution would not be my preference.
Unfortunately, this is not possible. The reason for this is that the else condition by itself would cause an error. You can split the cell using control+shift+subtract but once you try and run the last cell an error occurs. You can see the exact example of this in the picture I have included. Please let me know if you have any further questions/comments!
]1
这篇关于当 Jupyter 单元包含函数、循环或其他块时,是否可以跨单元拆分它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:当 Jupyter 单元包含函数、循环或其他块时,是否可以跨单元拆分它?


- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01