[Python-Dev] Exposing the Android platform existence to Python modules

Phil Thompson phil at riverbankcomputing.com
Sat Aug 2 22:38:37 CEST 2014


On 02/08/2014 7:36 pm, Guido van Rossum wrote:
> On Sat, Aug 2, 2014 at 12:53 AM, Phil Thompson 
> <phil at riverbankcomputing.com>
> wrote:
> 
>> To me the issue is whether, for a particular value of sys.platform, 
>> the
>> programmer can expect a particular Python stdlib API. If so then 
>> Android
>> needs a different value for sys.platform.
>> 
> 
> sys.platform is for a broad indication of the OS kernel. It can be used 
> to
> distinguish Windows, Mac and Linux (and BSD, Solaris etc.). Since 
> Android
> is Linux it should have the same sys.platform as other Linux systems
> ('linux2'). If you want to know whether a specific syscall is there, 
> check
> for the presence of the method in the os module.

It's not just the os module - other modules contain code that would be 
affected, but there are plenty of other parts of the Python stdlib that 
aren't implemented on every platform. Using the approach you prefer then 
all that's needed is to update the documentation to say that certain 
things are not implemented on Android.

Phil


More information about the Python-Dev mailing list