View Full Version : where can i test my python programs?
superplasmafist
April 13th, 2009, 10:58 AM
im new at programming so i dont know this.
but i write my codes in a text editor and save it as a .py.
now where can i check that it works? can i install something for this?
i tired the shell but that wasnt good
thanks
benj1
April 13th, 2009, 11:17 AM
just cd to the directory where your program is and
python your_program.py
runs your program in the python shell
or you can make your script executable
chmod +x your_program.py
then you can just run it by typing the program name.
just don't forget to add
#! /usr/bin/env python
to the start of your script
superplasmafist
April 13th, 2009, 11:29 AM
but the program doesnt work in the shell. is it something wrong with the program then?
arent there any other way? some app?
benj1
April 13th, 2009, 11:38 AM
if you're using ubuntu, python is installed by default
if you type 'python' in the terminal it should take you to a python shell
( your user name etc will be replaced by '>>>') you can quit by pressing ctrl-d. if this works and 'python script.py' doesn't, its something wrong with your script, if you post it we might be able to help
superplasmafist
April 13th, 2009, 11:47 AM
but i tried to write alittle more complex program. maybe i wrote the program wrong cause the simple ones works.
i post again when and if im sure it wasnt the code.
thanks
drubin
April 13th, 2009, 12:22 PM
#! /usr/bin/env python
to the start of your script
This is called a Shebang (http://en.wikipedia.org/wiki/Shebang_(Unix)).
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.