[Pythonmac-SIG] os.name ? and detecting platform...

Schollnick, Benjamin Benjamin.Schollnick at usa.xerox.com
Mon Mar 15 13:06:37 EST 2004


Folks,

	I left the list for while, but I'm back... >g<

	Seriously....  With MOSX 10.3 and Python 2.3x, what is the proper
way
	to detect we are running on MOSX?

	I use the following code, to "standardize" the testing process...

	But now, under MOSX, os.name is returning POSIX...
	Both on the system at home, and here at work.

	Is there a better way to insure that we are running on the Mac?

	As a I work around, I added another TRY block, which tries
	to import MacOS... 

			- Benjamin

# Check to see if we are running on a Macintosh based system.
# (Mac OS X or Classic)
#
macintosh	= (os.name == "mac")
_win32_loaded = 0

if not macintosh:
	try:
                # Check to see if we are running under Windows.
                #
		import win32api, win32con
		_win32_loaded = 1
	except:
		pass

#
#   Common Functions
#

platform_name = os.name
# Set a standardized variable for the platform name, which is based off the
# Os.name functions.
#



More information about the Pythonmac-SIG mailing list