The Python standard library includes a webbrowser module that allows you to open a new browser window or tab, regardless of platform. It supports Safari on OS X if it is the default user:
>>> import webbrowser
>>> webbrowser.open("http://stackoverflow.com")
But webbrowserdoes not support closing the browser window. For this level of control, your best bet is to use the Safari 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 webpage displayed on the open tab:
>>> safari.windows.first.current_tab.URL.set("http://www.google.com")
>>> safari.windows.first.current_tab.URL.set("http://www.python.com")
The Safari Apple Events interface is somewhat unintuitive (unfortunately, this is unusual for Mac apps). There are links if you need to do more complex things. But Python and py-appscript give you a solid foundation to work with.