Python platform Introduction














































Python platform Introduction



 Description:

There are many ways by which we can access the System information using python. Some of them are:- 
1.) platform module
2.) psutil
3.) subprocess
4.) wmi(only for windows)
5.) os module(only for Linux/Unix)

Here we are focusing on the platform module, platform is an in-built module that allows us to retrieve the system information(i.e. OS, OS version, Processor node, etc) about the platform on which the program is being currently executed.

 Why do we need a platform module?

This module plays a pivotal role when it comes to check the compatibility of the particular system hardware concerning the software to be installed. As it is an in-built module you do not require any installation.


 Syntax:
 import platform

 Platform Functions:

platform.node() - Returns the computer's network name. An empty string is returned if the value cannot be determined.

platform.system() - Returns the system/OS name, An empty string is returned if the value cannot be determined.

platform.release() - Returns the system's release, An empty string is returned if the value cannot be determined.

platform.machine() - Returns the machine type, An empty string is returned if the value cannot be determined.

platform.version() - Returns the system's release version, An empty string is returned if the value cannot be determined.

platform.uname() - Returns a tuple that stores information regarding the system.

platform.processor() - Returns the processor name.

platform.platform() - Returns a single string containing as much useful information that is retrievable about the system.

platform.architecture() - Returns a tuple that stores information about the bit architecture and linkage format.


NOTE: Along with the system information, the platform module can also be used to retrieve information about the Python software running on the system.

Some functions available for python software in the module are:

platform.python_build() - Returns a tuple associated with buildno, builddate stating the Python build number and date as strings.

platform.python_branch() - Returns a string identifying the Python implementation SCM(Source Code Manager) branch.

platform.python_version() - Returns a string that displays the version of Python running currently on the system.

platform.python_revision() - Returns a string identifying the Python implementation SCM  revision.

platform.python_compiler() - Returns a string identifying the compiler used for compiling  Python.

platform.python_version_tuple() - Returns the Python version as tuple (major, minor, patchlevel) of strings.

platform.python_implementation() - Returns a string identifying the Python implementation.

Since Python is a platform-independent language, it has modules that have functionalities specific to operating systems. Some of them are given below:


For Windows OS:
platform.win32_ver() - Returns a tuple  having information about Windows OS such as OS release, version number, service pack, OS type(single/multiprocessor).

platform.win32_edition() - Returns a string that represents the current Windows edition. Values include but are not limited to 'Enterprise', 'IoTUAP', 'ServerStandard', and 'nanoserver'.

platform.win32_is_iot() - Return True if the window edition returned by win32_edition() is recognized as an IOT edition.
 

For UNIX OS:
platform.libc_ver() - Returns a tuple storing information such as library and version of the UNIX OS.

For MAC OS:
platform.mac_ver() - Returns a tuple storing information such as release, version, machine about the MAC OS.



Example: Program to display machine type

#import module
import platform

#displaying machine type
print("Current Using Machine type is:",platform.machine())


OUTPUT:       


Comments