Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3760132
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:25:28+00:00 2026-05-19T10:25:28+00:00

I am relatively new to the mac world. My question concerns opening an application

  • 0

I am relatively new to the mac world. My question concerns opening an application using python on mac osx. From what I’ve found so far, it seems as if applications are stored in app format that are actually directories. Are these parsed somehow by the OS when opening the app? I would like to open Safari using python and it is in my /Applications/Safari.app directory. Is there a specific binary I should be passing to os.system or should I be going about it in a completely different way? My end goal is to have safari open a local html file, close it then open another local html file.

Thanks,
-John

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:25:28+00:00Added an answer on May 19, 2026 at 10:25 am

    The Python standard library includes the webbrowser module which allows you to open a new browser window or tab in a platform-independent way. It does support Safari on OS X if it is the user’s default:

    >>> import webbrowser
    >>> webbrowser.open("http://stackoverflow.com")
    

    But webbrowser does not support closing a browser window. For that level of control, you are best off using Safari’s Apple Event scripting interface by installing py-appscript.

    >>> from appscript import *
    >>> safari = app("Safari")
    >>> safari.make(new=k.document,with_properties={k.URL:"http://stackoverflow.com"})
    >>> safari.windows.first.current_tab.close()
    

    If you just want to change the web page displayed in the tab you opened:

    >>> safari.windows.first.current_tab.URL.set("http://www.google.com")
    >>> safari.windows.first.current_tab.URL.set("http://www.python.com")
    

    Safari’s Apple Events interface is somewhat non-intuitive (unfortunately, that’s not unusual with Mac applications). There are references out there if you need to do more complex stuff. But Python and py-appscript give you a solid base to work from.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new to web application programming so I hope this question isn't too
Relatively new to python. I recently posted a question in regards to validating that
I am relatively new to developing Cocoa applications on the Mac and come from
I'm relatively new to Python and am having problems programming with Scapy, the Python
I want to deploy an SWT application on Mac OS X. Since I'm relatively
I'm new to Python (relatively new to programing in general) and I have created
Relatively new to using database and for some reason I can't get this 'execute'
Relatively new to C# and MVVM, but I'm making a WP7 app using the
Relatively new to Cocoa here. This question is about NSFileHandle, but I got a
I relatively new to using Eclipse with the Android SDK. Whenever I encounter an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.