Products > Programming

Beginning Python Question

<< < (3/3)

TomS_:
You don't need to keep moving a statement one line at a time until you figure out where the error is, the error message (stack trace) tells you exactly where it is. I would definitely spend a bit of time familiarising yourself with the output of a stack trace because it can be a very useful debugging tool.

But maybe you can change your code a little bit to make this easier to work with. Assuming you are not creating a class to contain your code you could do the following:


--- Code: ---def main():
    Put your code in here

if __name__ == "__main__":
    main()
    input('Press Enter to Exit...')

--- End code ---

This gives you an exit prompt before your program exits whether it errors or not.

But to fix the whole issue of the window flashing up and disappearing, run your script from a terminal, i.e. the command prompt or inside an editor, directly. This way the window does not close once the script finishes running and you get to retain the output for later review.

rstofer:
It is worth knowing how to use Visual Studio Code as it can be used for a number of languages and on a number of platforms like Linux, macOS and Windows 8 and beyond.  No, it won't work on XP but I left that platform a long time ago.

If you have a wide monitor, it can be helpful to have two files displayed side-by-side at the same time.  Your main code and the library code simultaneously.

I also use Thonny for microPython on Windows.  It works well enough but it surely isn't VS Code. 

gedit and geany work well on Linux.  I run the code in a separate terminal from the editor.  Works well!

SiliconWizard:
Python stopped being supported on Win 7 as well, starting with version 3.7 or 3.8, not sure which one. So you'd need to grab an older version.
And not supported here means: not working at all, not just not being officially supported. At least if you use the official binaries. There are ways to build it for Win 7 at this point, but this is non-trivial and requires significant patching.

This in turn has caused many applications using Python one way or another, which otherwise would be still working plenty fine, to stop working on Win 7.

Bassman59:

--- Quote from: SiliconWizard on June 02, 2022, 05:34:45 pm ---This in turn has caused many applications using Python one way or another, which otherwise would be still working plenty fine, to stop working on Win 7.

--- End quote ---

One such application is KiCad. There was much gnashing of teeth by a dozen people running ancient hardware over KiCad dropping Python 2 and moving to whatever they call the latest Python 3 and the resulting end of support for Windows 7.

SiliconWizard:
It's also the case for mercurial (that I personally use.)
And many other applications, since Python has become sort of the de-facto scripting engine for applications, which uh... bites.

Navigation

[0] Message Index

[*] Previous page

There was an error while thanking
Thanking...
Go to full version