Page 1 of 1

Help with Python™

Posted: Tue Nov 17, 2009 5:03 pm
by 88EighT88
Hi i just downloaded python and i have allready got some of the basic very easy language actually can some just tell me how i can debug and run the script?

Thanx

Posted: Tue Nov 17, 2009 5:36 pm
by CodeX
as far as debugging goes the only option I'm aware of is running the script through a console such (cmd.exe or command.com), then when any errors occur they are printed out in the console and do not disappear when the script terminates. If you're sticking to simple things you can use www.codepad.org to run your code and display the output (it doesn't support anything involving sockets and you cant use file I/O) which is really good for practising as you can do it anywhere, its quick and even has syntax highlighting. I think its using Python 2.6.4 (as its the standard on debian) which has slight differences to 3

p.s these colours are done with a python script :P

Posted: Tue Nov 17, 2009 5:52 pm
by 88EighT88
Thanx for reply and do you think u could give me the script? :D

Posted: Tue Nov 17, 2009 6:03 pm
by 88EighT88
Ok so i tried that Cmd.exe thing and its giving errors then i try Python Command line and its gives a syntax error no description just "There is a syntax error" any suggestions?

any specific Cmds i should be running other than open ("dir") (python comline) run dir (cmd)?

any extension i should be adding?

Posted: Tue Nov 17, 2009 6:31 pm
by CodeX
I would send you it but I'd much rather see you make your own, it's a good way to lean (plus it makes the posts ~40 times larger so I probably shouldn't promote this too much).

you can just do
python "Z:\my files\my folder\my script.py"
in the command line to save you the 'cd' hastle, and the syntax errors you just have to figure out yourself (might take a bit of time) which you simply do by reading through the code and checking things, it could be something like you have = instead of == or too much going on on a single line.

Posted: Tue Nov 17, 2009 11:56 pm
by PaRaDoX
Also, make sure you installed python correctly (changed certain environment variables / options, etc.)

Posted: Wed Nov 18, 2009 4:23 am
by 88EighT88
PaRaDoX wrote:Also, make sure you installed python correctly (changed certain environment variables / options, etc.)
Can you please tell me how to do this Paradx?

the cmd command isnt running it...

Posted: Wed Nov 18, 2009 10:31 pm
by PaRaDoX
88EighT88 wrote:
PaRaDoX wrote:Also, make sure you installed python correctly (changed certain environment variables / options, etc.)
Can you please tell me how to do this Paradx?

the cmd command isnt running it...
Depends what error you're getting. If its a syntax error, make sure you followed the instructions on the python site. Can't remember the exact thing it tells you to do, but I remember that it had something to do with the window where you change environment variables, this kinda thing that eliminated the need to go to the python directory, it made all the commands global.

Posted: Wed Nov 18, 2009 11:02 pm
by CodeX
you can add the python directory to the PATH variable so it searches that directory for executables, here's a link about adding to the PATH:
http://www.computerhope.com/issues/ch000549.htm
once that's done you can simply do this to start a python session (assuming the python executable is called python which is probably is):

Code: Select all

python "my file.py"
or if you just want to open an interactive session to play with:

Code: Select all

python
try not to mess up your path by replacing all the paths with a single new one (your PATH should be a semicolon separated list of paths and not just a single path)

Posted: Wed Nov 18, 2009 11:48 pm
by PaRaDoX
CodeX wrote:you can add the python directory to the PATH variable so it searches that directory for executables, here's a link about adding to the PATH:
http://www.computerhope.com/issues/ch000549.htm
once that's done you can simply do this to start a python session (assuming the python executable is called python which is probably is):

Code: Select all

python "my file.py"
or if you just want to open an interactive session to play with:

Code: Select all

python
try not to mess up your path by replacing all the paths with a single new one (your PATH should be a semicolon separated list of paths and not just a single path)

YEA! that was it :P


Thanks, that was bugging me for a while >.>

Posted: Thu Nov 19, 2009 7:29 am
by Liidian
Or you could have used python GUI from the start >.>

Posted: Thu Nov 19, 2009 12:35 pm
by 88EighT88
THANX ALOT!!!

Posted: Thu Nov 19, 2009 11:49 pm
by PaRaDoX
Liidian wrote:Or you could have used python GUI from the start >.>
Meh, command line has a charm to it :3