Search code examples
pythonpython-idledatanitro

Python shell issue when using Data Nitro


I am using DataNitro to write Python Script in Excel. Its very useful indeed. However, when I open the Idle editor in excel, the accompanying Python Shell is not interactive, in that it does not return print statements, show errors, nothing. It just restarts every time I run the programme. This makes it incredibly hard to debug as I can't use print statements to trace the errors.

Does anyone know if this is a bug with DataNitro, or is it supposed to be that way, or whats going on? are there any solutions?

Thanks so much


Solution

  • Our IDLE editor is just an editor - it doesn't work as a shell.

    The best way to debug programs is to raise an exception. This will freeze the shell that opens when a script is run, and you'll be able to inspect the variables and see any print statements that were generated during execution.

    For example, if you run:

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

    You'll see the value of A1 printed to the shell, and you can enter "x" at the prompt to see the value of B1.

    You can also import a script you're working on into the regular Python shell (the one that opens when you press "shell"). This will execute the code in that script.

    We'll be adding a guide to debugging code to the site soon, as well as some features that make it easier.

    Source: I'm one of the founders of DataNitro.