Problem with python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mac_the_scotte@hotmail.com

    Problem with python

    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
  • Lie

    #2
    Re: Problem with python

    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.

    Comment

    • Scott David Daniels

      #3
      Re: Problem with python

      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
      Scott.Daniels@A cm.Org

      Comment

      • castironpi@gmail.com

        #4
        Re: Problem with python

        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.

        Comment

        • Paul McGuire

          #5
          Re: Problem with python

          On Mar 30, 12:34 am, castiro...@gmai l.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

          Comment

          • Lie

            #6
            Re: Problem with python

            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.pytho n

            Comment

            Working...