Detecting OS platform in Python

MrJean1 MrJean1 at gmail.com
Fri Jan 11 12:53:12 EST 2008


On Jan 10, 7:53 pm, Benjamin <musiccomposit... at gmail.com> wrote:
> On Jan 10, 8:37 pm, Devraj <dev... at gmail.com> wrote:> Hi everyone,
>
> > My Python program needs reliably detect which Operating System its
> > being run on, infact it even needs to know which distribution of say
> > Linux its running on. The reason being its a GTK application that
> > needs to adapt itself to be a Hildon application if run on devices
> > like the N800.
>
> platform.dist might help you. It's not very complete at all, though.
> (This is supposed to improve in 2.6, though)
>

Better yet, first use  sys.platform.  If that is 'linux2', then use
platform.dist().

/Jean Brouwers


> > I have been searching around for an answer to this, and did find some
> > messages on a lists that suggested the use of sys.platform to detect
> > platform, with counter posts saying that it didn't work on Windows
> > etc.
>
> > Can anyone please shed some light on this?
>
> > Thanks a lot.




More information about the Python-list mailing list