[Python-ideas] Determine Windows version in platform module

Giampaolo Rodola' g.rodola at gmail.com
Fri Dec 27 19:48:52 CET 2013


On Fri, Dec 27, 2013 at 7:38 PM, M.-A. Lemburg <mal at egenix.com> wrote:

> On 27.12.2013 19:18, Giampaolo Rodola' wrote:
> > Today I was looking for a way to determine whether I was on Windows >=
> > Vista and couldn't find anything so I came up with this [1].
> >
> > That led me to think about platform module.
> > Honestly I can't see the usefulness of it as it doesn't give you any
> usable
> > API to figure out what platform version you're on.
>
> Have you had a look at the documentation ?
>
>
> http://docs.python.org/2.7/library/platform.html?highlight=platform#windows-platform


Yes, on Windows XP I get a tuple like this:

('XP', '5.1.2600', 'SP3', 'Uniprocessor Free')

On Windows 7:

('7', '6.1.7600', '', 'Multiprocessor Free')

Neither of those are helpful to make assumptions such as "if I'm on Windows
>= XP with SP3: do something".
The real deal would be dealing with a tuple of integers in order to use
comparison operators, similarly to sys.version_info:

if sys.version_info >= (3, 0):
     # py3-specific code


--- Giampaolo
https://code.google.com/p/psutil/
https://code.google.com/p/pyftpdlib/
https://code.google.com/p/pysendfile/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131227/56af69c6/attachment.html>


More information about the Python-ideas mailing list