admin管理员组

文章数量:1289877

So I have a python app that reads/loads a file that is sort of like a plugin for the main application.

I would really like to be able to debug (step into) the code from VSCODE - which I'm using as an IDE

I've tried a number of things, described here (and related posts)

How to debug python code running inside exec()

These are not working.. I do end up in the pub shell in the terminal window, but that is not really what I was hoping for.

Why? What I have is a large directory (forest) of various data directories. Each subdirectory contains a body of data, and I want to have a "customization script" - that I can execute for that subdirectory. Sort of like a PLUGIN of sorts

So I get to the point where I have the name of the file, I can read the file and I want to "exec()" the contents (string) of that file, and I really want to step into the script being executed.

how can I do this?

EDIT: jan-13 I was asked for an minimally reproducible example, so I am adding one.

# Normally this code would come from a file I open and read
# In this example I have it as a multi-line string.
code='''
for x in range(0,100):
    print("Hello %d" % x)
'''
# I want to step into the above code using some IDE (ANY IDE)
# I currently use VSCODE but another is just as good.
exec( code )

Launch the above in an IDE and try to step through the 'code'

本文标签: vscodepythonstep through code being 39exec39edStack Overflow