By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,985 Members | 1,574 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,985 IT Pros & Developers. It's quick & easy.

Problem with python

P: n/a
Hi there.
I downloaded python a couple of days ago from the official site and
have started writing simple programs in the python gui (this being my
first attempt at programming ever). The only thing is when I write
python code in a text editor and save it as a .py file, when I double
click it all that happens is a black box flashes up on the screen, but
nothing else!?

At first I thought this was because I had only written a hello world
program, and that the box had displayed "hello world" and then closed.
But then I wrote a program requiring user input and the same thing
happened... Am I doing something wrong?

Thanks in advance for any help!

//mac
Mar 29 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Lie
On Mar 30, 2:57*am, mac_the_sco...@hotmail.com wrote:
Hi there.
I downloaded python a couple of days ago from the official site and
have started writing simple programs in the python gui (this being my
first attempt at programming ever). The only thing is when I write
python code in a text editor and save it as a .py file, when I double
click it all that happens is a black box flashes up on the screen, but
nothing else!?

At first I thought this was because I had only written a hello world
program, and that the box had displayed "hello world" and then closed.
But then I wrote a program requiring user input and the same thing
happened... Am I doing something wrong?

Thanks in advance for any help!

//mac
open the program in IDLE (or any other Python IDEs). I'm guessing that
your program is printing a traceback (error) when trying to get input
that's why it immediately closes itself.
Mar 29 '08 #2

P: n/a
Lie wrote:
On Mar 30, 2:57 am, mac_the_sco...@hotmail.com wrote:
>Hi there.
I ... started writing simple programs in the python gui... when I write
python code ...[and]... double click it all that happens is a black box
flashes up on the screen, but nothing else!? ....

open the program in IDLE (or any other Python IDEs). I'm guessing that
your program is printing a traceback (error) when trying to get input
that's why it immediately closes itself.
Another possibility is to open a shell (or command window or "dos box"),
and in that window type in "python myfile.py" You'll see error messages
because the display window does not depend on the program staying alive.

By the way, a better thing to have said when you asked this would
include your OS, the python version, and the GUI system you are using.
Those details matter. If you are doing wxPython programming, for
example, you cannot easily use IDLE for your program (GUI systems
fight for control of the display).

-Scott David Daniels
Sc***********@Acm.Org
Mar 29 '08 #3

P: n/a
On Mar 29, 5:33*pm, Scott David Daniels <Scott.Dani...@Acm.Orgwrote:
Lie wrote:
On Mar 30, 2:57 am, mac_the_sco...@hotmail.com wrote:
Hi there.
I ... started writing simple programs in the python gui... *when I write
python code ...[and]... double click it all that happens is a black box
flashes up on the screen, but nothing else!? ....
open the program in IDLE (or any other Python IDEs). I'm guessing that
your program is printing a traceback (error) when trying to get input
that's why it immediately closes itself.

Another possibility is to open a shell (or command window or "dos box"),
and in that window type in "python myfile.py" You'll see error messages
because the display window does not depend on the program staying alive.

By the way, a better thing to have said when you asked this would
include your OS, the python version, and the GUI system you are using.
Those details matter. *If you are doing wxPython programming, for
example, you cannot easily use IDLE for your program (GUI systems
fight for control of the display).
The screen is real (r-e-a-l): all manners intended. Real. Just bid
and auction.
Mar 30 '08 #4

P: n/a
On Mar 30, 12:34*am, castiro...@gmail.com wrote:
>
The screen is real (r-e-a-l): all manners intended. *Real. *Just bid
and auction.
Please leave the newbies alone. They have enough trouble just getting
their Python environments running, without trying to decipher your
pseudo-profound chatterbot-speak.

-- Paul
Mar 30 '08 #5

P: n/a
Lie
mac_the_sco...@hotmail.com wrote to me:
(snip)
OK thanks mate you're the man :)
One more question though :P
If I write a python script in a text editor (I use Programmers
Notepad), how do I write indentations properly? e.g.:
---------------------------------------------------
temperature = input("How hot is the spam? ")
while temperature < hot_enough:
print "Not hot enough... Cook it a bit more..."
sleep(30)
temperature = input("OK. How hot is it now? ")
print "It's hot enough - You're done!"

(taken from hetland.org)
---------------------------------------------------
Is it simply a case of hitting the spacebar until it looks right?
Yep, it's just a matter of hitting spacebar until it looks right, but
you should also be aware that the Python Interpreter doesn't like it
if you mix tabs and spaces, so make sure you only use either one of
them. As an additional note, Python's style guideline says you should
use 4 spaces (additionally, most Python IDEs automatically convert
tabs into 4 spaces for convenience and to avoid mixing tabs and
cases).

PS: I'll mirror this to comp.lang.python
Mar 30 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.