Python - Run Row by Row

Dear Python Experts,
I was wondering if it is possible to run python script row by row.
Some scripts (especially with for loop one) it is hard to understand mistakes at the script and make correction?
What you can suggest to run python row by row?
Thanks in advance.

Unfortunately you cannot execute python line by line within Dynamo since the Dynamo graph execution happens all at once (more or less). You can use print() (in Dynamo 2.8 and later) to print to the console for data confirmation while the code runs but that’s about it.

Thanks Nick,
what about preparing sciprt at different python editor and use it inside dynamo python?
Any suggestion?

Suggestions for writing in an external editor and then transferring code to Dynamo python? Many people do that. As long as you’re using the same (or similar enough) python version and conscious about any external modules or libraries then you should be fine. There’s nothing specific that you have to worry about.

1 Like

Many Thanks Nick,
Any external editor software you can suggest me? (which can be run line by line while monitoring some parameter values.)
I am using python 3 at dynamo.

You should have no issue running code line by line in an actual IDE. The most common would probably be Visual Studio / Visual Code. Another popular option for testing python, especially with Revit, is pyRevit but I don’t believe it has breakpoints for line by line execution.

1 Like

Including the code or relevant sections in a try/except statement where you return the traceback results in the exception can help here, and allow processing multiple errors at once. Search the forum for ‘traceback.format_exc’ for examples.

@kvusal ,

what do mean row by row? i had an issue to divide my task in steps, element by element it works finally well.

KR

Andreas

Hi,
the implementation of a logger can also be a solution (inside Dynamo context)

4 Likes