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

    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    Python Beginner, Mac help - running python programs in MacOs


    Hi Everyone,

    New to the Python language, and to any code language at that (excluding bad websites in the 00s involving lots of scrolling marquees and animated cursors)

    Anyhow, I'm trying to learn python from Michael Dawson's 'Python programming for the absolute beginner'. However, I've run into a snag as the book is intended for a windows user whereas I have a macbook. Have read a few helpsheets else where and tried using terminal, but the thing is I'm not used to the terminology etc. have followed these instructions and hasn't worked.

    How do I run a python program on a Mac directly, That runs this correctly
    -----
    # Game Over
    # Demonstrates the print function

    print("Game Over")

    input("\n\nPress the enter key to exit.")
    -----

    When running in Idle it just prints it, pressing enter doesn't exit the program as the book says it should as its in interactive mode.

    Someone please advise, I'm feeling like a class-A idiot right now. Would like to move past chapter 1, haha.
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,735
    Rep Power
    507
    You succeeded with the lesson, proceed to the next.



    When a program intended for Microsoft Windows ends in
    "press enter to exit"
    it is just an assumption that the windows console user doesn't know how to adjust the settings for "DOS command windows" to remain open after the program terminates. Otherwise, running the program would flash by so fast the windows user might see nothing at all.


    I don't have a Mac. Your OS10 is some unix variant. I don't know if python is on your PATH . From a unix terminal console run your program using the command
    ($\ is the shell prompt)

    $ python file.py

    You used some editor to create a text file named
    file.py
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo