Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102491
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Tim Golden <mail@timgolden.me.uk> |
| Newsgroups | comp.lang.python |
| Subject | Re: .py file won't open in windows 7 |
| Date | Thu, 4 Feb 2016 13:09:05 +0000 |
| Lines | 53 |
| Message-ID | <mailman.59.1454591350.30993.python-list@python.org> (permalink) |
| References | <VI1PR06MB1118687ADB4F37E783DD027FE0D10@VI1PR06MB1118.eurprd06.prod.outlook.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de DUw7QLLR6idTLgOUmxaEuAkcPshwBsz8Tmjr2JQrgH5g== |
| Return-Path | <mail@timgolden.me.uk> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '"""': 0.05; 'sys': 0.05; '__name__': 0.07; 'main()': 0.07; 'subject:file': 0.07; '(without': 0.09; 'advice.': 0.09; 'runs,': 0.09; 'python': 0.10; 'def': 0.13; 'interpreter': 0.15; "'__main__':": 0.16; '.py': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'main():': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'quotes)': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'run.': 0.16; 'seconds.': 0.16; 'subject:windows': 0.16; 'tjg': 0.16; 'url:faq': 0.16; 'wrote:': 0.16; 'basically': 0.18; 'result,': 0.18; '(in': 0.18; 'variable': 0.18; 'windows': 0.20; 'to:name:python-list@python.org': 0.20; 'to:2**1': 0.21; 'ones.': 0.22; 'this:': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'command': 0.26; 'error': 0.27; 'dos': 0.27; 'prints': 0.29; 'repair': 0.29; 'environment': 0.29; 'code:': 0.29; 'starts': 0.29; 'program,': 0.29; 'code': 0.30; 'window': 0.30; 'run': 0.33; 'options': 0.33; 'url:python': 0.33; 'open': 0.33; 'case,': 0.34; 'file': 0.34; 'add': 0.34; 'something': 0.35; 'but': 0.36; 'list,': 0.36; 'instead': 0.36; 'url:org': 0.36; 'closing': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'two': 0.37; "won't": 0.38; 'drop': 0.38; 'stuff': 0.38; 'end': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'url:3': 0.60; 'your': 0.60; 'charset:windows-1252': 0.62; 'from:addr:mail': 0.70; 'eg:': 0.84; 'happened.': 0.84; 'url:functions': 0.84 |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 |
| In-Reply-To | <VI1PR06MB1118687ADB4F37E783DD027FE0D10@VI1PR06MB1118.eurprd06.prod.outlook.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc1 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:102491 |
Show key headers only | View raw
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
print(stuff)
if __name__ == '__main__':
sys.exit(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")
https://docs.python.org/3/faq/windows.html#how-do-i-run-a-python-program-under-windows
* Instead of use sys.exit immediately, add input("Press enter...") to
the end of your code:
https://docs.python.org/3/library/functions.html?highlight=input#input
eg:
result = main()
input("Press enter...")
sys.exit(result)
* set the PYTHONINSPECT environment variable for your user
https://docs.python.org/3/using/cmdline.html#envvar-PYTHONINSPECT
* Use a shebang line "#!python -i" (without the quotes) at the top of
your program.
https://docs.python.org/3/using/windows.html#shebang-lines
These last two options will drop into the Python interpreter after your
code has run.
TJG
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: .py file won't open in windows 7 Tim Golden <mail@timgolden.me.uk> - 2016-02-04 13:09 +0000
csiph-web