For instance, say I have some snippet of self-contained code in a cell,
In [1]
from sys import argv
print(argv[1])
I want to be able to pass a value to the code in that cell, presumably through magic, so that
In [2]
%expelliarmus "In [1]" 69105
outputs
69105
Is there any simple way for me to do this, ideally without having to write the cell to my disk as a script?
Edit: I can't just wrap it in a function because in the notebook I'm working in (not the example I posted above) I'm trying to test stuff out with the argparse module.
def cell_one(x): ...
then simply calling that from cell two? – Crossbeamargparse
because you're not writing a command-line script. – Risottogoto
on line numbers when I was learning qBasic in middle school, in that your asking the code to do something that isn't consistently defined. It's not something you're going to find in many (any?) modern languages. – Roeser