3

I'm new to python and I'm having fun. So far I've only been on the road in VBA and SQL, but one thing bothers me. Is there no feature that goes through the code line by line like in VBA? This has always helped me a lot with VBA (F8), I could check the value of the variable on the fly (hold mouseover), i could check the whole code better and see where exactly it is running on a bug. Is this function not really available in python? I use PyCharm as IDE

Thanks!

3
  • 1
    You might like Jupyter Notebooks Commented Jan 11, 2020 at 18:09
  • pdb is a great tool for debugging code line by line docs.python.org/3/library/pdb.html Commented Jan 11, 2020 at 18:10
  • 1
    You are looking for a debugger. pdb is adequate by itself, but there are a lot of great tools that exist for it in various IDEs (e.g. PyCharm) and text editors (vscode). Use one Commented Jan 11, 2020 at 20:50

3 Answers 3

4

You may try the following command: python -m pdb <script.py>. It will run the script in the Python debugger where you can traverse your code step by step.

Sign up to request clarification or add additional context in comments.

Comments

0

There is nothing like VBA/VB6 IDE for python, unfortunately. Microsoft's IDE is simply unmatched in terms of debugging convenience. As a language, Python is more powerful, but good debugging solution is yet to come, you can't chance lines execution order or alter code on the fly in the debugger.

Comments

0

Yes, not as fine as you can do in VBA, but in Pycharm you can actually click on the gap between the line number and the code, it will add a red circle there meaning that's as stop point much like VBA, just like pressing the F8 key to advance a line.

To run the code in debug mode on PyCharm, just right click anywhere in the code and select "Debug 'mycode.py'" (cn't miss the green bug icon).

But when I say 'not as fine as VBA' it's mainly because unfortunatelly, unlike VBA, you can't edit your code while running on debug mode.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.