[Pythonmac-SIG] How to get MacOS X version?

Bob Ippolito bob at redivi.com
Wed Mar 29 21:27:12 CEST 2006


On Mar 29, 2006, at 10:54 AM, Russell E. Owen wrote:

> How can I get the version of MacOS X within a python program?
> (e.g. 10.4.5 -- something that is recognizable, rather than the kernel
> version).
>
> In theory I can get it from gestalt, but I haven't figured out how  
> to do
> it via the Carbon package, or even if it's possible.
>
> Any hints?

platform.mac_ver() -- this is almost definitely broken on Python  
2.3.5 on Intel though, because Carbon.* and gestalt are mostly broken  
there.  The reliable way that has always and should always work is to  
parse either /usr/bin/sw_vers or /System/Library/CoreServices/ 
SystemVersion.plist.

> P.S. I'm going to be trying to figure out the same thing for unix and
> even Windows. I think I know how to do those, but if you happen to  
> know
> or have sample code, that'd be great.

Probably also in the platform module...

-bob



More information about the Pythonmac-SIG mailing list