User input for graph file format

Hi all!
I have a requirement in my project that the user should be able to select the output file format, that is, if he wants graphviz to generate the graph as a pdf, svg etc,
Currently, I have this is my python code:

Render the graph

graph.render('graphviz_cnet', format='pdf', cleanup=True)

Display the graph

graph.view()

So, I assume that if I get the user input in a variable let’s say ‘file_format’, I could simply substitute it in my code:
graph.render(‘graphviz_cnet’, format=file_format, cleanup=True)

Or does anyone know a better way?

Thanks!

Yes

Yes you can substitute a variable in there

1 Like

Nice!
Thank you for the reply!