.py file won't open in windows 7

Tim Golden mail at timgolden.me.uk
Thu Feb 4 08:09:05 EST 2016

On 04/02/2016 12:52, Yossifoff Yossif wrote:
> Hallow,
> I try to open a .py file (attached), but what I get is a windows DOS window opening and closing in a couple of seconds. Ran repair of the program, nothing happened.
> I cannot see error messages and don't know where to look for ones.
> Would appreciate your piece of advice.

Attachments won't make it through to the list, Yossif. But your code is
basically something like this:

import sys

def main():
  # calculate stuff

if __name__ == '__main__':

In that case, the program starts (in a console window), runs, prints the
result, and then closes. You've got a few simple ways of seeing the output:

* Run the program from the command line (start a console window in the
directory where the code is and type "ss7calc.py")


* Instead of use sys.exit immediately, add input("Press enter...") to
the end of your code:



result = main()
input("Press enter...")

* set the PYTHONINSPECT environment variable for your user


* Use a shebang line "#!python -i" (without the quotes) at the top of
your program.


These last two options will drop into the Python interpreter after your
code has run.


More information about the Python-list mailing list