Python Forum
Is there a better way of formatting os.uname() output?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a better way of formatting os.uname() output?
#3
If can write cross platform try to do that,os.uname only work on Linux.
With platform should be able to get same info.
Can make a list and use getattr with those strings as attribute access for platform.
import platform

os_info = ['machine', 'version', 'system', 'release']
for item in os_info:
    print(getattr(platform, item)()) 
Output:
AMD64 10.0.19041 Windows 10
On Linux Repl.it
Output:
x86_64 #19~20.04.1-Ubuntu SMP Thu Aug 12 05:25:25 UTC 2021 Linux 5.11.0-1017-gcp
Reply


Messages In This Thread
RE: Is there a better way of formatting os.uname() output? - by snippsat - Aug-27-2021, 05:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Formatting float number output barryjo 2 980 May-04-2023, 02:04 PM
Last Post: barryjo
  Formatting to output file Mark17 2 1,376 Jan-13-2022, 09:06 PM
Last Post: BashBedlam
  Is there a better way to print uname information? EkaCaesium 4 3,874 Apr-26-2021, 12:51 PM
Last Post: EkaCaesium
  Output formatting Steffenwolt 0 2,209 Jan-18-2018, 03:47 PM
Last Post: Steffenwolt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020