Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.04; 'happen,': 0.07; 'key.': 0.07; 'subject:Question': 0.07; 'python': 0.09; 'cmd': 0.09; 'interpreter,': 0.09; 'script,': 0.09; 'typed': 0.09; 'useless': 0.09; 'windows,': 0.09; 'cc:addr:python-list': 0.10; 'yet.': 0.13; 'folks': 0.15; 'bugs.': 0.16; 'closes': 0.16; 'cmd,': 0.16; 'did.': 0.16; 'invisible': 0.16; 'newsgroup.': 0.16; 'subject:program': 0.16; 'windows:': 0.16; 'wrote:': 0.17; 'specify': 0.17; 'shell': 0.18; '>>>': 0.18; 'windows': 0.19; 'meant': 0.21; 'latter': 0.22; 'please?': 0.22; 'stick': 0.22; 'runs': 0.22; 'cc:2**0': 0.23; 'work.': 0.23; "haven't": 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'skip:" 20': 0.26; 'first,': 0.27; 'guess': 0.27; 'question': 0.27; 'dos': 0.27; 'mind.': 0.27; "doesn't": 0.28; 'correct': 0.28; 'run': 0.28; 'post': 0.28; '(perhaps': 0.29; 'clicked': 0.29; 'running.': 0.29; 'case,': 0.29; 'window': 0.30; 'function': 0.30; 'system,': 0.32; 'running': 0.32; 'could': 0.32; 'subject: .': 0.33; 'subject:Simple': 0.33; 'subject:regarding': 0.33; 'anyone': 0.33; 'that,': 0.34; 'version': 0.34; 'changed': 0.34; 'program,': 0.34; 'filter': 0.35; 'open': 0.35; 'pm,': 0.35; 'posting': 0.35; "won't": 0.35; 'list.': 0.35; 'but': 0.36; "didn't": 0.36; 'should': 0.36; 'problems': 0.36; 'subject:: ': 0.38; 'some': 0.38; 'received:192': 0.39; 'called': 0.39; 'google': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'end': 0.40; 'your': 0.60; 'containing': 0.61; 'first': 0.61; 'here': 0.65; 'charset:windows-1252': 0.65; 'gave': 0.65; 'frequently': 0.65; 'matter.': 0.65; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'all!': 0.84; 'around,': 0.84; "it'd": 0.84; 'launches': 0.84; 'run?': 0.84; 'subject:running': 0.84 Date: Mon, 12 Nov 2012 21:24:38 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Caroline Hou Subject: Re: Simple Question regarding running .py program References: In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:HdOSCMBdFW9W4jtaIGUjY8/YfuwPQTahDH4s73t1OU/ 7sBo9cqXw15AVzajL4FqVQb/xJad8CsTswBFLOhGwuerRJc1D6 Qb8g5EN7OlH7GCa1aS/24Iq9RbRqflBIbTBsr7UglF7bhWcqFd PhYeoNY0zDcLo8NQCDACf79ZStOlwL6ab/q6tug9JW+Oe46Vic lDREFkVPVRJbUCPna/fSxklKs3okakbft/h1TY1diZWEkLMO+I wlxfTL5hWvNiQJCjrFR+OAS1NQfE3tG3EspoRq+JXMoRgrdXHE 7iYSD6t/IC5VSIaKaZMsNP+7FrM3puaPDdxMUMIQE9eSb9EcA= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352773507 news.xs4all.nl 6865 [2001:888:2000:d::a6]:44681 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33214 On 11/12/2012 09:02 PM, Caroline Hou wrote: > Hi all! > > I just started learning Python by myself and I have an extremely simple question now! > I am in my Python interpreter now and I want to open/edit a program called nobel.py. But when I typed >>> python nobel.py, it gave me a "SyntaxError:invalid syntax”( I've changed to the correct directory)what should I do? > I also want to run the program, but as I double-clicked the program, a command window pops up and closes immediately. How can I see the result of the program run? > Could anyone help me please? I am pretty confused here...Thank you! It'd be nice to specify that you're running Windows, and also what version of the interpreter, although in this case the latter doesn't matter. Go to a shell (cmd.exe), change to the directory containing that script, and type the command as you did. On linux: davea@think:~$ python nobel.py On Windows: c:\mydir\myscript > python nobel.py If you're already in the python interpreter, then running python is useless -- it's already running. In that case, you might want to use import. However, I recommend against it at first, as it opens up some other problems you haven't experience with yet. When you say you "double clicked the program', we have to guess you might have meant in MS Explorer. If you do that, it launches a cmd, it runs the python system, and it closes the cmd. Blame Windows for not reading your mind. If you want the cmd window to stick around, you COULD end your program with an raw_input function call, but frequently that won't work. The right answer is the first one above... Open a shell (perhaps with a menu like DOS BOX), change... That way, when the program finishes, you can see what happened, or didn't happen, and you can run it again using the uparrow key. BTW, you don't need to send email to both the python-list and to the newsgroup. The newsgroup is automatically fed from the list. But since you're posting from google groups, that's just one of the bugs. Many folks here simply filter out everything from google groups, so your post is invisible to them. -- DaveA