I have one data point, perhaps relevant.

In the static type checking world we only care about coarse distinctions.
PEP 484 states that type checkers should understand sys.platform. It does
not require anything else. In practice, this is used almost exclusively to
check for 'win32', since lots of APIs are different on Windows. (In all of
typeshed there's a single check for 'darwin', meaning macOS, vs. currently
89 checks for 'win32'.)

On Mon, Jun 17, 2019 at 9:31 AM Steve Dower <steve.do...@python.org> wrote:

> On 16Jun2019 2354, Michael wrote:
> > CONCERN: How to organize platform dependent blocks of code
> > POLICY/RECOMMENDATION: (today) seems to be: arbitrary, although
> > sys.platform, seems to be the favorite.
> >
> > * I, as 'python-consumer' was very surprised when I learned that
> > sys.platform is "set" when Python is built - and that platform.system()
> > was the call to make to get the run-time value. And, of course, they
> > answered the "question" - what platform am I 'running' on, quite
> > differently.
> >
> > * There are several - to many - issues in the past where, in one form or
> > another, sys.platform, platform.system(), os.name, and I expect more but
> > cannot think of them atm - used throughout all of Python.
> >
> > * A Python expert (e.g., core-devs) may understand - inherently - when
> > each of these is the best option.
> > As an 'experienced-novice' I am surprised that a "build-time constant"
> > seems to be preference. This preference is not new (maybe
> > platform.system() is "new", and os.name() too broad).
>
> To help focus the discussion a bit, I recommend looking at what we've
> already covered in https://bugs.python.org/issue36624
>
> There really is an apparent lack of consistency in the test suite where
> we use sys.platform, os.name and platform module checks to determine
> whether a test should be run or not. This no doubt extends throughout
> the standard library.
>
> As Michael points out, sys.platform is a specific compile-time constant,
> os.name is a vague compile-time constant, and the platform module
> returns runtime values.
>
> It's entirely possible that the mixed uses are correct, and that we are
> correctly using sys.platform to test things that are based on
> compile-time constants, correctly using os.name to choose between the
> major flavors of posixmodule.c, and so on. But it's not obvious that we
> are doing that, and it's not obvious what the correct choice should be
> in any situation.
>
> We could do with improving the guidance we provide in this area. And as
> Michael says, we are the ones with the knowledge and ability to provide
> that guidance. So this is really a call for opinions on "how should we
> do platform-specific conditions".
>
> Cheers,
> Steve
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/TYARZX6XOFPAHEMUW3G5RUZACRLA64Z5/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him/his **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/QMFAX2IFHRZX7FMV3Q4YN7N7T3R6E3R6/

Reply via email to