Python Syntax Error

Discussion in 'Mac Programming' started by WMBenham, Sep 8, 2010.

  1. macrumors newbie

    Jul 20, 2010
    Hey all,

    I just started learning Python and am working in IDLE. My very first tutorial suggested I try the basic "Hello, World" test and when I input
    print "Hello, World"
    I get an invalid syntax error. Am I missing something here?
  2. macrumors 603


    Mar 27, 2009
    The World Inbetween
    Functions need brackets around them.

    What python tutorial are you using? I might be able to get you/point to something better and more up-to-date (PM me)
  3. Moderator emeritus


    Aug 16, 2005
    That works for me in Python 2.6.1. The need for parens on print is something that has changed in Python.
  4. macrumors 604

    Aug 9, 2009
    The following works for me. Mac OS 10.6.3.

    First, launch Enter this command:
    python -m idlelib.idle
    A few seconds elapse, then a separate Python Shell window appears with the copyright notice, firewall message, and finally the >>> prompt. Example from an IDLE tutorial:
    except mine says IDLE 2.6.1.

    I then type in:
    print "Hello, world"
    and hit Return. It prints what I typed in.

    This isn't the only way to run Python's IDLE, but it does work here.

    I suggest copying the contents of the IDLE window that shows the command and resulting error message, and pasting it into a post. It's as simple as cmd-A (Select All), cmd-C (Copy) in the IDLE window, then paste it into a reply post and surround it with CODE tags.

    It would be a good idea to identify exactly which OS version and Python version you're using, along with the IDLE version. Also, if you're using rather than the command-line I entered, or some other way of starting IDLE, that should also be identified.

Share This Page