On Dec 27, 2013, at 10:48, "Giampaolo Rodola'" <g.rodola@gmail.com> wrote:


On Fri, Dec 27, 2013 at 7:38 PM, M.-A. Lemburg <mal@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


So you want to write:

    if platform.win_version_info >= (5, 1, 2600):

Is that really much better than:

    if platform.win32_ver.version >= '5.1.2600':

There are a few cases with older windows versions where the third component is 3 digits, and it's always possible that could be true again, but I don't think it affects anything you're likely to be checking for in 2014.

If you want some different number... then what? It would be nice if Microsoft had a nice numbering scheme so
Windows 7 was 7 rather than 6.1, 2003 wasn't sometimes 5.1 and sometimes 5.2, etc. But they don't.

Meanwhile, Microsoft's suggested solution is that you not check for version numbers at runtime, but instead check for features. And there are good reasons for that--for example, XPSP3 N has exactly the same version numbers as XPSP3 normal, but if you try to use the new Windows Media APIs, you'll crash.

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/