FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Python help





morfeusman
Well i am a noob to python and i can't seen to get python to do anything.
i save this as project.py:
Code:
#file:project.py
print "hello world"
#end

It keeps poping up in a ms-dos window and then the window disapears.

What can i be doing wrong?!
Peterssidan
The "ms-dos window" is probably only visible as long as the program is running. your program prints and then ends so you will have no time to see what happens. Maybe you can start an "ms-dos window" and run your program from there. That way the window will not go away when the program ends.
morfeusman
Quote:
The "ms-dos window" is probably only visible as long as the program is running. your program prints and then ends so you will have no time to see what happens. Maybe you can start an "ms-dos window" and run your program from there. That way the window will not go away when the program ends.

How do i do that?
Peterssidan
I don't know Python so I don't know exactly how to do it.

I guess you use an IDE so there might be some option you can change to make the window stay. Probably easier.
morfeusman
I looked through the IDE, nothing was there to format the program in anyway.
Any other suggestions?
Peterssidan
What IDE are you using?
morfeusman
I am using python 2.4(if that's what you are asking for) but i'm not sure python has an IDE.
i am using notepad ++ as an editor if thats was you mean.
Peterssidan
I see.. How do you execute your python program now?
morfeusman
i double click program.py
Peterssidan
ah such magic

Put a raw_input at the end of the program like this:
Code:
#file:project.py
print "hello world"
raw_input("Press <Enter> to exit. ")
#end
morfeusman
thank you sooooooooooooooooooooooo much! now i can do python!
gameproff
I would also recommend getting IPython (and Console optional). (Which is basically my Python development environment along with Notepad++)

IPython is an interactive python console, that lets you run/debug your scripts as well as do things like provide help, command completion, interactive object exporer and a lot more.

Once you download, install and run it, just change to the directory where your script is and type %run script.py, or %run -d script.py to debug it.

That way you can write scripts without needing to use raw_input at the end all the time Smile

If all this is too much a simple suggestion is just using the cmd prompt in Windows, switching to the directory with the script and typing its name.

Good luck!
blueray
The alternative way was donwload pythonwin.
It was an interactive IDE with debugger support.

http://docs.python.org/using/windows.html#additional-modules
Buba_vv
python distribution has integrated IDE called IDLE. It is simple but enough to do basic development
holygrail
I've tried a bunch of ide's with python:

Aptana IDE with PyDev package
Eclipse IDE with pydev package
Pyscripter is a nice ide for simple scripts with an integrated console output it's hosted on google
and of course all the others that come with the distro of python:
Activestate
Idle
IronPython

some are not free:
Komodo Python Ide
Wingware

At the moment I'm using a highly customized emacs for python developing. Sounds weird but it's best suited for me because i can switch the interpreter to check for compatibility.

Cheers,
Arthur.
Related topics
Python beginners help!
Python...
Python via CGI - A personal triumph
Python via CGI - A personal triumph
Session handlers in Frihost using Python? Help Needed!
developing a game in python
Python
Can't get python working
Is there a Python Hello World using Apache?
Python automation [SOLVED]
website in python
Python v Perl v php for Wiki advice needed
Java, python, or c++?
help python
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.