Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Simple Question regarding running .py program (http://www.velocityreviews.com/forums/t954452-simple-question-regarding-running-py-program.html)

Caroline Hou 11-13-2012 02:02 AM

Simple Question regarding running .py program
 
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!

Dave Angel 11-13-2012 02:24 AM

Re: Simple Question regarding running .py program
 
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


Caroline Hou 11-13-2012 02:45 AM

Re: Simple Question regarding running .py program
 
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 simplequestion 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 theinterpreter,while if I just want to run a python program, I should use DOSshell 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

Caroline Hou 11-13-2012 02:45 AM

Re: Simple Question regarding running .py program
 
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 simplequestion 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 theinterpreter,while if I just want to run a python program, I should use DOSshell 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

Terry Reedy 11-13-2012 06:21 AM

Re: Simple Question regarding running .py program
 
On 11/12/2012 9:45 PM, Caroline Hou wrote:

> 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?


IDLE is one way to edit; I use it. When you want to run, hit F5 and
stdout and stderr output goes to the shell window.

--
Terry Jan Reedy


Ramchandra Apte 11-13-2012 12:35 PM

Re: Simple Question regarding running .py program
 
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 Ido?

>
> >

>
> > > 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 programrun 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.

Caroline Hou 11-14-2012 03:31 AM

Re: Simple Question regarding running .py program
 
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 programcalled nobel.py. But when I typed >>> python nobel.py, it gave me a "SyntaxError:invalid syntax”( I've changed to the correct directory)what shouldI 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 resultof 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 usethe interpreter,while if I just want to run a python program, I should useDOS 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 anarticle or book that covers such basic stuffs!

>
> >

>
> > Thank you!

>
> >

>
> >

>
> >

>
> > Caroline Hou

>
>
>
> IDLE is recommended for newbies like you because an IDE requires too muchconfiguration.
>
> 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?

Chris Angelico 11-14-2012 04:10 AM

Re: Simple Question regarding running .py program
 
On Wed, Nov 14, 2012 at 2:31 PM, Caroline Hou <joyhou2010@gmail.com> wrote:
> 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?


There are several ways to communicate with this list.

* The comp.lang.python newsgroup - get a newsreader (there are plenty
around), and either connect to your ISP's news server (if they have
one that carries c.l.p) or to a public server, some of which cost
money.
* Use a news-to-web gateway such as Google Groups. That specific one
is deprecated on this list, as there's more noise than signal from
Google Groups.
* The mailing list python-list, delivered directly to your inbox many
times a day. This is what I personally use.

Try here:
http://mail.python.org/mailman/listinfo/python-list

ChrisA

rurpy@yahoo.com 11-14-2012 05:08 AM

Re: Simple Question regarding running .py program
 
On 11/13/2012 09:10 PM, Chris Angelico wrote:
> On Wed, Nov 14, 2012 at 2:31 PM, Caroline Hou wrote:
>> 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?

>
> There are several ways to communicate with this list.
> [...]
> * Use a news-to-web gateway such as Google Groups. That
> specific one is deprecated on this list, as there's more
> noise than signal from Google Groups.


Caroline, Chris is mistaken about this, if for no other
reason than there is no authority here empowered to decide
to deprecate anything. What Chris should have said is
that there are some people on this list who don't like
Google Groups for whatever reason and encourage others
to ignore posts from Google Groups.

How successful this boycott effort is is not clear.

I use Google Groups as it suits my needs better than
any of the alternatives, and so do many others. Both
of the other alternatives Chris mentioned involve too
much setup or overhead for those who read/post here
only occasionally. GG fills this niche adequately
if used with care.

If you do use Google Groups to post, there are a
couple of things you should be careful of:

* You'll sometimes see a checkbox above the GG send
window that is a CC to the python mailing list
(<pytho...@python.org>) which is checked by default.
Uncheck that before sending, or the list will get
two copies of your message.

* GG doesn't do a very good job in quoting the post
you are replying to. If you look at your recent
post here:
http://mail.python.org/pipermail/pyt...er/635070.html
(or on GG) you will see lots and lots of lines empty
save for the ">" quote markers. This makes a post
hard to read.

A way to avoid this is to remove the blank extra blank
lines in the GG send window by hand before posting.

Alternatively, many email programs have a "paste as
quotation" option when writing mail. What I do is
to open a blank new email message, copy the original
post I'm replying to from GG, paste-as-quotation into
the new mail window, then copy and paste back into the
GG send window. Pretty easy to do once you get used
to it.

Hope this helps and provides a little more accurate
info about posting from GG than has been provided so
far.


Chris Angelico 11-14-2012 06:02 AM

Re: Simple Question regarding running .py program
 
On Wed, Nov 14, 2012 at 4:08 PM, <rurpy@yahoo.com> wrote:
> On 11/13/2012 09:10 PM, Chris Angelico wrote:
>> * Use a news-to-web gateway such as Google Groups. That
>> specific one is deprecated on this list, as there's more
>> noise than signal from Google Groups.

>
> Caroline, Chris is mistaken about this, if for no other
> reason than there is no authority here empowered to decide
> to deprecate anything. What Chris should have said is
> that there are some people on this list who don't like
> Google Groups for whatever reason and encourage others
> to ignore posts from Google Groups.
>
> How successful this boycott effort is is not clear.


To be more accurate: This is deprecated *by members of* this list. As
there is no commanding/controlling entity here, it's up to each
individual to make a decision - for instance, abusive users get
killfiled rather than banned. The use of Google Groups to post is
deprecated in the original sense of the word: strongly disapproved of.

My own opinion on the matter is that if it takes as much effort as you
describe to use GG properly, it's wasting your time on a massive
scale. Surely it's easier to read and post email?

ChrisA


All times are GMT. The time now is 01:13 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.