2016-10-31 16:15:31

How to replace deprecated platform.distro()

The Python method platform.distro() have been deprecated since Python 3.5. And it will be removed in Python 3.7. So it is about time to really replace it in your (and my) code.

Fortunately there is a new python module "distro". I packaged it for Fedora and EPEL so it should be available in main repository now. It is available as python2-distro and python3-distro.

The replacement is quite easy. Instead of:

import platform
platform.dist()

you just put there:

import distro
distro.linux_distribution(full_distribution_name=False)

and that's all.


Posted by Miroslav Suchý | Permanent link
Comments
comments powered by Disqus