#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    13
    Rep Power
    0

    Facing problem in running program and need a solution


    Hello, I am new to python. stared learning python only. At first , I downloaded python 2.4 and there i had run some program successfully. But today I downloaded python 3.3. I tried to run those program in python 3.3 which i run in python 2.4 successfully but those programs are not working in 3.3. i didn't make any changes in program. it shows syntax error every time. I am not understanding whats happening.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0
    Originally Posted by superversion970
    it shows syntax error every time. I am not understanding whats happening.
    Python 2 and 3 have different syntax rules. You'll have to read the differences on the website. If you're just learning, stick with Python 2.x

    Python 2 code will note run in python 3
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,900
    Rep Power
    481

    2to3


    The most likely problem is print.
    In python3 print is a function, not a statement.

    print 'my string'
    is a python 3 syntax error just as is
    math.sin math.pi/3


    raw_input no longer exists in python3, although that wouldn't cause syntax error.


    Use python's 2to3 tool to convert your program from version 2 to version 3. The program handles most everything. On my system (shell prompt "$ " it is)

    $ 2to3-2.7 --help

    I've only used it once myself, but then again I started using python3 while it was an early beta release.
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    13
    Rep Power
    0

    Thank you for the answer


    Originally Posted by jadedrakerider
    If you're just learning, stick with Python 2.x
    If I learn python 2.x and after that when I will start learning 3.x ,will I have to learn form the beginning ? or 2.x and 3.x are same without some differences?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    13
    Rep Power
    0

    Thank you


    Originally Posted by b49P23TIvg


    Use python's 2to3 tool to convert your program from version 2 to version 3. The program handles most everything.
    I am interested in python 3.x . can you please give me some links for python 3.x tutorial?
  10. #6
  11. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,900
    Rep Power
    481
    Guido handed out a short python3 cheat sheet at one of the python conferences. Mine is long lost, and I don't see it on the web.
    Here find a longer one.

    Look up python3k, python3000, and the PEPs starting from number 3000.

    GVR on python3
    http://www.python.org/dev/peps/pep-3000/
    [code]Code tags[/code] are essential for python code and Makefiles!
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    13
    Rep Power
    0
    Thank you

IMN logo majestic logo threadwatch logo seochat tools logo