[IPython-dev] magics and metadata
Tue Jun 19 10:08:51 CDT 2012
Yes, it would not be good to have the API of cell magics be notebook
specific. What about providing a reference to the current cell metadata in
the Magics class that can be used to update the NotebookNode after
executing cell.input? So, cell_magics would not have access to the metadata
on execution but could pass any metadata it wanted to back to the notebook.
This is already sort of possible if you're willing to go through the
outputs of the cell on the frontend by a hack along the lines of
metadata["type"] = "cell_metadata"
Followed by (on the front end)
for output in cell.outputs:
if (output.json is not None and "type" in output.json and
output.json['type'] == "cell_metadata"):
This will obviously have a problem if metadata had a key called "type" but
maybe its logic could be encapsulated into an "update_cell_metadata"
On Tue, Jun 19, 2012 at 2:48 AM, Thomas Kluyver <email@example.com> wrote:
> On 19 June 2012 09:18, Jonathan Taylor <firstname.lastname@example.org>
> > With the addition of cell-level metadata in cells in ipython/master it
> > be nice to be able to easily add metadata to cells, say, through a cell
> > magic?
> I agree that there are reasons why the user might want to alter the
> metadata, but I don't think cell magics are the way to do it. Cell
> magics are run in the kernel, which doesn't know about the frontend.
> And you can use cell magics in the qt console or the terminal, so
> their API can't be notebook specific.
> IPython-dev mailing list
Dept. of Statistics
Sequoia Hall, 137
390 Serra Mall
Stanford, CA 94305
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev