Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 20th, 2004, 12:52 AM   #1
Insomniac
Programmer
 
Insomniac's Avatar
 
Join Date: Aug 2004
Location: Cloud #9
Posts: 47
Rep Power: 0 Insomniac is on a distinguished road
Still very new to this.

Ive gone through the tutorials many times and Im simply convinced there's something wrong with my version.

Right now, and usually when Im writing, I have 3 tabs. The command line, the shell, and the editor.

Ok, fine. I write out a sample program in the editor and go to run it, it asks me to save which is cool.

Then the program runs in the shell nicely.

The problem lies when I try to run the program on the command line with 'python (name of program)'. I always get a syntax error. I followed the writing and saving or saving and finding the programs directions to the T, but I can't seem to run a program using the 'python' command or I can't at all run a program on the command line. Whats up?

Further, when Python asks me to save a program which Ive just written before running it, I do and I give it a name... but I dont see the other programs in there at all. Even when I use, 'start, run, browse, foldername' it's not there. Where did they go??

The only way I can open a saved program is by using the editor and clicking File, Open... that's it!

There's gotta be other ways, no?
__________________
From an IBM Thinkpad T43 - 14.1" SXGA+ - ATI 64 MB X300 - Sonoma 760 - 2 GB RAM - 80 GB HD 5400 - IBM ABG II - FC3, Ubuntu & XPee
DevC++, and Macromedia's - Dreamweaver & Flash Pro and a little Adobe Illustrator & Photoshop
Sleep? Sleep is for the weak.:cool:

Insomniac is offline   Reply With Quote
Old Aug 20th, 2004, 1:01 AM   #2
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 720
Rep Power: 11 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Make sure you've saving the files as .py and when you run them from a command line don't forget to add the .py extension. The version shouldn't make a differnce.

Also, if you could give me the exact error you recieve that would be a great help.

Make sure that CMD.exe is in the right directoy. For example when I open CMD it starts out in C:\Documents and Settings\FPHA and if I want to run a python script that I saved in C:\Python as script.py I have to type the following in.



cd C:\Python
python script.py


Hope that helps out!

:-D
thechristelegacy is offline   Reply With Quote
Old Aug 20th, 2004, 1:39 AM   #3
Insomniac
Programmer
 
Insomniac's Avatar
 
Join Date: Aug 2004
Location: Cloud #9
Posts: 47
Rep Power: 0 Insomniac is on a distinguished road
This is messed up.



I did the simple program, Hello. - one line, on the editor. When I went to run it, Shell asked to save it, so I saved it hello.py, then shell runs it.

I try it at the Command line. Nothing.

I go back into the shell, click File, click open, the window opens and my file is not there.

Im lost.

As for the other things.... Python23 looks like this: C:\Python23 and thats it.

Error message after typing : python hello.py

File "<stdin>", line 1
python hello.py
^ - (directly under the o)
SyntaxError: invalid syntax
__________________
From an IBM Thinkpad T43 - 14.1" SXGA+ - ATI 64 MB X300 - Sonoma 760 - 2 GB RAM - 80 GB HD 5400 - IBM ABG II - FC3, Ubuntu & XPee
DevC++, and Macromedia's - Dreamweaver & Flash Pro and a little Adobe Illustrator & Photoshop
Sleep? Sleep is for the weak.:cool:

Insomniac is offline   Reply With Quote
Old Aug 20th, 2004, 1:47 AM   #4
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 720
Rep Power: 11 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Quote:
Originally posted by Insomniac@Aug 20 2004, 02:39 AM
Error message after typing : python hello.py

File "<stdin>", line 1
python hello.py
^ - (directly under the o)
SyntaxError: invalid syntax
That's the python interpreter, not you're command window. To run the program you need to use the command window.

To open a command window, click start, RUN and type CMD.exe

When that window comes change your directory to whevrever you save your python files (default is the python directory).

To change your directoy from inside the command window type


cd C:\Python23 (or whatever directory your script might be saved in)

and then type

python script.py


Make sure to try that from inside the command window and not the Python interpreter.
thechristelegacy is offline   Reply With Quote
Old Aug 20th, 2004, 2:07 AM   #5
Insomniac
Programmer
 
Insomniac's Avatar
 
Join Date: Aug 2004
Location: Cloud #9
Posts: 47
Rep Power: 0 Insomniac is on a distinguished road
OMG, lol.

Thank you legacy.

Why do we use the CMD.exe ? That's simliar or it IS Dos, no? Dangit I read nowhere on those tutorials that says to open this specific line.

Where that error was, you said intepreter... the tutorial says 'if you open the file and its lists 'Python, version, date, system' at the top and then copyright stuff, and has NO drop down menus, and also has the >>> then you're at the command line.'

Their tutorial needs to say exactly what you said, 'start, run, cmd.exe'. - would've been a time saver. Sheesh.

Ok, now Im able to pull up those .py files correctly.

So that I have this correctly, there exists the editor for writing them, the shell for running them, command line for executing them, and what is the intepreter for? I have that one open and I haven't used it yet after a couple of days.

Thanks again Legacy
__________________
From an IBM Thinkpad T43 - 14.1" SXGA+ - ATI 64 MB X300 - Sonoma 760 - 2 GB RAM - 80 GB HD 5400 - IBM ABG II - FC3, Ubuntu & XPee
DevC++, and Macromedia's - Dreamweaver & Flash Pro and a little Adobe Illustrator & Photoshop
Sleep? Sleep is for the weak.:cool:

Insomniac is offline   Reply With Quote
Old Aug 20th, 2004, 2:17 AM   #6
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 720
Rep Power: 11 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
When the tutorial said command line, it meant the command line persion of Python, not that actual command window. The command line version of python is the interpreter. It runs things on the spot. For example, in the interpreter with the >>> prompt you can type hello world and hit enter and runs it right away (insteaf od saving it and running it with CMD.exe)

>>>print "Hello, World." #then you hit enter and see
Hello, World
It's basicly for doing things on the fly. And when you say editor do you mean Idle? You stated four things, when there are only three.

Quote:
Originally posted by Insomniac

here exists the editor for writing them, the shell for running them, command line for executing them, and what is the intepreter for
I believe you mean you have the editor (Idle), then you have the interpreter or shell which is the window with the >>> prompt, and then you have the command prompt (CMD.exe) to exicute the code. Hope that clears things up for ya!

Glad to see you got everyting working out. You'll be coding in no time
thechristelegacy is offline   Reply With Quote
Old Aug 20th, 2004, 9:06 AM   #7
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,740
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
can you give us the code you where using it mite help us figure out what could be wrong
__________________
BIG K aka Kyle
Programming Forums
Kydovik Web Development

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Aug 20th, 2004, 9:34 PM   #8
Insomniac
Programmer
 
Insomniac's Avatar
 
Join Date: Aug 2004
Location: Cloud #9
Posts: 47
Rep Power: 0 Insomniac is on a distinguished road
uhm....

yea, it's simple:

print "Hello."







The problem was in trying to recall this program on the intepreter by 'hello.py'. I used to type that in and got nothing. But, after Legacies' patience, Im now able to pull up saved programs.

__________________
From an IBM Thinkpad T43 - 14.1" SXGA+ - ATI 64 MB X300 - Sonoma 760 - 2 GB RAM - 80 GB HD 5400 - IBM ABG II - FC3, Ubuntu & XPee
DevC++, and Macromedia's - Dreamweaver & Flash Pro and a little Adobe Illustrator & Photoshop
Sleep? Sleep is for the weak.:cool:

Insomniac is offline   Reply With Quote
Old Aug 22nd, 2004, 9:07 PM   #9
erebus
Programmer
 
erebus's Avatar
 
Join Date: Aug 2004
Location: /dev/null
Posts: 65
Rep Power: 10 erebus is on a distinguished road
Send a message via AIM to erebus
Quote:
Originally posted by Insomniac@Aug 20 2004, 07:07 AM
Why do we use the CMD.exe ? That's simliar or it IS Dos, no? Dangit I read nowhere on those tutorials that says to open this specific line.
CMD is a command interpreter that issues with NT and up(NT, 2000, XP, Srv03). You could have just as easily used command.com which is the legacy aged MS-DOS derived command interpreter that uses external programs as shell commands. CMD has the comodity of having everything integrated and nicely packaged into the executable, and uses very little external programs for command execution. Hit F1 and find the DOS command reference for more information. Just a final note: command emulators on NT systems are NOT in any way DOS, since in that, you're calling them Disk Operating Systems. I can't say the same for 9x/Me . Hope that helped. Legacy got the rest of it just right.
__________________
<span style='font-size:14pt;line-height:100%'><span style='color:red'>&quot;Political power grows out of the barrel of a gun&quot; - Mao Tse-Tung</span></span>
erebus is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:12 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC