Python shell issue when using Data Nitro

I am using DataNitro to write Python Script in Excel. It is very useful. However, when I open the Idle editor in excel, the companion Python shell is not interactive, because it does not return print reports, it shows errors, nothing. It just restarts every time I run the program. This makes debugging difficult since I cannot use print instructions to track errors.

Does anyone know if this is a bug with DataNitro, or should it be so, or what happens? are there any solutions?

Thank you very much

+4
source share
2 answers

Our IDLE editor is just an editor - it does not work like a shell.

The best way to debug programs is to throw an exception. This will close the shell that opens when the script starts, and you can check the variables and look at any print instructions that were created at run time.

For example, if you run:

print Cell("A1").value x = Cell("B1").value raise 

You will see that the A1 value is printed in the shell, and you can enter “x” at the prompt to see the B1 value.

You can also import the script you are working with into a regular Python shell (the one that opens when you click "shell"). This will execute the code in the script.

In the near future we will add a guide for debugging code on the site, as well as some functions that facilitate it.

Source: I am one of the founders of DataNitro.

+3
source

Not as knowledgeable as Ben, but he used DataNitro quite a bit, and here are some tips:

The shell automatically closes after running the script. If you want to check some fingerprints or even interact with the shell, I usually place it at the end of my script.

 raw_input("Press Enter to Exit shell") 

Not very elegant, but I even created a small loop that displays text options in the console. You can then interact with your program and worksheet. A smarter and more elegant way would be for your polling script to highlight the excel cell and then apply the action form.

Something else that might seem nice to you is that it also launches Ipython instead of the default python shell. I can’t imagine how to use python without Ipython ... so you get the benefits of debugging Ipthon debugging, etc. To activate this, simply click on the “Use Ipython” checkbox in the DataNitro settings (I don’t know if this depends on the version).

+3
source

Source: https://habr.com/ru/post/1486201/


All Articles