Skip to content
Advertisement

Argparse in iPython notebook: unrecognized arguments: -f

I am trying to pass a .py file to ipython notebook environment. I have never had to deal directly with argparse before. How do I rewrite the main() function?

I tried to delete the line of def main(): and keep the rest of the code.

But args = parser.parse_args()” returned an error:

ipykernel_launcher.py: error: unrecognized arguments: -f.

And when I run . %tb: showing this

JavaScript

Advertisement

Answer

It’s better to use @nbro ‘s answer for Jupyter execution.

JavaScript

If you want to manage parameters as class format, you can try this.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement