Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

python for mac

  • 11-12-2009 3:45pm
    #1
    Registered Users, Registered Users 2 Posts: 57 ✭✭


    I have started learning python language, and while its very interesting and i can understand most of the tutorials ok, thay all seem to be for windows. i know the code is the same on any platform but when i follow the directions to save the file with .py at the end somewhere, and try to open it, it just opens the IDLE window with all the code in it.

    In whatever tutorials I see, when the .py file is clicked it opens just with whatever 'enter name' command that was written, without all the code.

    Is there a different way to save .py files on a mac?


Comments

  • Closed Accounts Posts: 1,397 ✭✭✭Herbal Deity


    Open a terminal and type 'python myfile.py'?


  • Registered Users, Registered Users 2 Posts: 57 ✭✭darklow


    nope, if i type that into the terminal it just comes up no such file or directory, i have it in a file on the desktop, do i have to specify a path to python where the files are? if so how?

    also i need to be able to save the applications i make to be opened by anybody without terminal or python

    im working at the moment with a graphical language called max/msp for music programme, tis cool but i want to branch out into python too


  • Registered Users, Registered Users 2 Posts: 3,568 ✭✭✭ethernet


    darklow wrote: »
    nope, if i type that into the terminal it just comes up no such file or directory, i have it in a file on the desktop, do i have to specify a path to python where the files are? if so how?
    You need to change directory first (to your desktop). When you open the terminal, you'll be in your home directory
    /Users/<username>/
    
    so you need to:
    cd Desktop
    
    first.

    Well, that or:
    python Desktop/foobar.py
    

    Now try it!


  • Registered Users, Registered Users 2 Posts: 57 ✭✭darklow


    cool man cheers that worked! do i have to type that path it every time? when i try open it with:

    python myfile.py

    it doesn't.


    also, is there a way i can save the .py file so i can open it straight away without terminal? the tutorials seem to show it being opened from the desktop/folder like a normal application


  • Registered Users, Registered Users 2 Posts: 760 ✭✭✭mach1982


    Mac use the mach kernel, which is UNIX based, so if look to learn to use command line just google linux/unix there 99% the same


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,419 ✭✭✭Cool Mo D


    darklow wrote: »
    cool man cheers that worked! do i have to type that path it every time? when i try open it with:

    python myfile.py

    it doesn't.


    also, is there a way i can save the .py file so i can open it straight away without terminal? the tutorials seem to show it being opened from the desktop/folder like a normal application

    A good program to use is http://www.barebones.com/products/textwrangler/
    This is a texteditor like IDLE, but has a some nicer features. One of them is that it has 'run' as a command in the menu bar. So if you use it to write your python programs, you can run them directly from the editor.

    If you want the scripts to run when you click on them, a way that should work (but I haven't tried, so maybe it doesn't!) is to click on a script, press option-i to get the Inspector window, and set the script to open with the python interpreter program by default.

    If you save your python programs in the desktop, you can open the terminal, type:

    cd ~/Desktop
    python myfile.py

    and it will work.

    cd is the Unix change working directory command. The ~ is Unix shorthand for your home directory - it is the same as /Users/Me.


Advertisement