ipython - How to export one cell of a jupyter notebook? - Data Science Stack Exchange
        
                
            
        
        
        
        Fri Jul 08 2022 22:44:01 GMT+0000 (Coordinated Universal Time)
        Saved by
            @mdlenin
        
        
            
                from IPython.core.magic import register_cell_magic
@register_cell_magic
def run_and_save(line, cell):
    'Run and save python code block to a file'
    with open(line, 'wt') as fd:
        fd.write(cell)
    code = compile(cell, line, 'exec')
    exec(code, globals())
%%run_and_save hello.py
class Hello:
   def __init__(self):
      pass
             
            content_copyCOPY
         
        
        https://datascience.stackexchange.com/questions/13669/how-to-export-one-cell-of-a-jupyter-notebook
     
  
        
Comments