Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33292

Re: Simple Question regarding running .py program

Newsgroups comp.lang.python
Date 2012-11-13 19:31 -0800
References <fbc6ecf4-9aa9-4b29-9308-0ed81a3b5bf9@googlegroups.com> <mailman.3605.1352773507.27098.python-list@python.org> <22ae6963-6700-4ea7-b396-344d89ead7f2@googlegroups.com> <8085ebf2-9f08-4889-84c9-f786d6776001@googlegroups.com>
Message-ID <dd71b452-5ef9-489b-b4d1-5e9d8d08e8f6@googlegroups.com> (permalink)
Subject Re: Simple Question regarding running .py program
From Caroline Hou <joyhou2010@gmail.com>

Show all headers | View raw


On Tuesday, November 13, 2012 7:35:32 AM UTC-5, Ramchandra Apte wrote:
> On Tuesday, 13 November 2012 08:15:45 UTC+5:30, Caroline Hou  wrote:
> 
> > On Monday, 12 November 2012 21:25:08 UTC-5, Dave Angel  wrote:
> 
> > 
> 
> > > 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
> 
> > 
> 
> > 
> 
> > 
> 
> > Hi Dave!
> 
> > 
> 
> > 
> 
> > 
> 
> > thank you very much for your quick reply! I did manage to get the program run from cmd.exe. 
> 
> > 
> 
> > So does it mean that if I want to use python interactively,I should use the interpreter,while if I just want to run a python program, I should use DOS shell instead?
> 
> > 
> 
> > Also, how could I edit my script? I have sth called "IDLE" installed along with python. Is it the right place to write/edit my script?
> 
> > 
> 
> > Sorry about these semi-idiot questions but it is really hard to find an article or book that covers such basic stuffs! 
> 
> > 
> 
> > Thank you!
> 
> > 
> 
> > 
> 
> > 
> 
> > Caroline Hou
> 
> 
> 
> IDLE is recommended for newbies like you because an IDE requires too much configuration.
> 
> When you start writing a big project, you can use an IDE.

Thank you Dave and everybody here for your helpful comments!This place is awesome! I found this group when I googled python-list. Seems like this is not the usual way you guys access the list?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Simple Question regarding running .py program Caroline Hou <joyhou2010@gmail.com> - 2012-11-12 18:02 -0800
  Re: Simple Question regarding running .py program Dave Angel <d@davea.name> - 2012-11-12 21:24 -0500
    Re: Simple Question regarding running .py program Caroline Hou <joyhou2010@gmail.com> - 2012-11-12 18:45 -0800
      Re: Simple Question regarding running .py program Terry Reedy <tjreedy@udel.edu> - 2012-11-13 01:21 -0500
      Re: Simple Question regarding running .py program Dave Angel <d@davea.name> - 2012-11-13 04:25 -0500
      Re: Simple Question regarding running .py program Ramchandra Apte <maniandram01@gmail.com> - 2012-11-13 04:35 -0800
        Re: Simple Question regarding running .py program Caroline Hou <joyhou2010@gmail.com> - 2012-11-13 19:31 -0800
          Re: Simple Question regarding running .py program Chris Angelico <rosuav@gmail.com> - 2012-11-14 15:10 +1100
            Re: Simple Question regarding running .py program rurpy@yahoo.com - 2012-11-13 21:08 -0800
              Re: Simple Question regarding running .py program Chris Angelico <rosuav@gmail.com> - 2012-11-14 17:02 +1100
                Re: Simple Question regarding running .py program rurpy@yahoo.com - 2012-11-13 23:02 -0800
                Re: Simple Question regarding running .py program rusi <rustompmody@gmail.com> - 2012-11-13 23:52 -0800
                Re: Simple Question regarding running .py program Chris Angelico <rosuav@gmail.com> - 2012-11-15 00:35 +1100
                Re: Simple Question regarding running .py program rurpy@yahoo.com - 2012-11-14 10:20 -0800
                Re: Simple Question regarding running .py program Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-14 23:07 +0000
                Re: Simple Question regarding running .py program rurpy@yahoo.com - 2012-11-14 15:57 -0800
                Re: Simple Question regarding running .py program Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-15 00:30 +0000
                Re: Simple Question regarding running .py program rurpy@yahoo.com - 2012-11-15 13:29 -0800
                Re: Simple Question regarding running .py program Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-15 22:15 +0000
                Re: Simple Question regarding running .py program Grant Edwards <invalid@invalid.invalid> - 2012-11-16 02:55 +0000
                Re: Simple Question regarding running .py program Duncan Booth <duncan.booth@invalid.invalid> - 2012-11-22 11:35 +0000
                Re: Simple Question regarding running .py program rusi <rustompmody@gmail.com> - 2012-11-15 20:10 -0800
                Re: Simple Question regarding running .py program Chris Angelico <rosuav@gmail.com> - 2012-11-16 17:37 +1100
                Re: Simple Question regarding running .py program Chris Angelico <rosuav@gmail.com> - 2012-11-16 17:38 +1100
                Re: Simple Question regarding running .py program Terry Reedy <tjreedy@udel.edu> - 2012-11-14 20:18 -0500
          Re: Simple Question regarding running .py program Terry Reedy <tjreedy@udel.edu> - 2012-11-14 20:08 -0500
    Re: Simple Question regarding running .py program Caroline Hou <joyhou2010@gmail.com> - 2012-11-12 18:45 -0800

csiph-web