ipython display figure

Stestagg stestagg at gmail.com
Tue Apr 13 12:51:59 EDT 2021


I'm guessing here a little bit, but it looks like the author expects you to
run this code in a jupyter notebook, rather than in an ipython interactive
console.

The jupyter and ipython projects are related (the same?) which can cause
some confusion, but if you run the code you shared in a jupyter lab
environment, then the SVG should display.

As an example, you should be able to view the expected SVG in the following
google colab book:

https://colab.research.google.com/drive/10KL9mV92L8yPe_5wL089C-m6i0N8ct7Q?usp=sharing

 Steve

On Tue, Apr 13, 2021 at 3:12 PM Peng Yu <pengyu.ut at gmail.com> wrote:

> Hi,
>
> https://www.fuzzingbook.org/html/Grammars.html
>
> I am trying to follow an example on the above page. But it does not
> show a figure. Could anybody let me know how to display the figure?
>
> $  ipython3
> Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)
> Type 'copyright', 'credits' or 'license' for more information
> IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help.
>
> [ins] In [1]: from fuzzingbook.Grammars import *
>
> [ins] In [2]: from IPython.display import SVG, display
>
> [ins] In [3]:
> SVG(show_diagram(syntax_diagram_expr(EXPR_GRAMMAR['<term>'][0])))
> Out[3]: <IPython.core.display.SVG object>
>
> --
> Regards,
> Peng
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list