473,396 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Get OS name

How can I get the OS Name, such as "Windows XP Pro". I know I can do

sys.getwindowsversion but that doesnt return a nice Windows XP Pro
string.

and os.name gives "nt"

thanks.

Jul 19 '05 #1
5 3026
rbt
codecraig wrote:
How can I get the OS Name, such as "Windows XP Pro". I know I can do

sys.getwindowsversion but that doesnt return a nice Windows XP Pro
string.

and os.name gives "nt"

thanks.


Read the docs... sys.getwindowsversion() should do the trick. AFAIK,
there is no way to differentiate between XP Home and Pro unless you
attempt to call an executable that's only available on Pro... such as
"systeminfo". If that call fails, it's reasonably safe to assume that
you're on a XP Home machine... especially if getwindowsversion()
produces a major of 5 and a minor of 1

As everyone knows that XP is really just NT 5.1 ;)
Jul 19 '05 #2
i guess i wanted the result in a nice string like Windows XP instead of
5.1

i guess i'll have to convert it myself, thanks

Jul 19 '05 #3
"codecraig" wrote:
How can I get the OS Name, such as "Windows XP Pro" i guess i wanted the result in a nice string like Windows XP instead of
5.1

i guess i'll have to convert it myself, thanks
your requirements keep changing. to get the OS name in a platform-
independent way, use the platform module:
python
import platform
print platform.system(), platform.release() Windows XP

$ python import platform
print platform.system(), platform.release()

Linux 2.4.18-3

etc.

(tip: reading the "library reference" table of contents a couple of times is a great way
to learn about the contents of the standard library. http://docs.python.org/lib/lib.html )

</F>

Jul 19 '05 #4
my requirements for getting the OS info havent changed. My first
message says "How can I get the OS Name, such as "Windows XP Pro"."
.....that's what I wanted all along.

thanks for the information anyway, i believe platform is better than my
previous approach.

thanks

Jul 19 '05 #5
codecraig wrote:
my requirements for getting the OS info havent changed. My first
message says "How can I get the OS Name, such as "Windows XP Pro"."
....that's what I wanted all along.

thanks for the information anyway, i believe platform is better than my previous approach.

thanks


Please note that platform appears to require win32api to be in your
system. The following is the code from \Lib\platform.py.

The function that gets the data sets these values as default

[Code from platform.py]
def win32_ver(release='',version='',csd='',ptype=''):
[/code]

And will return empty strings in case win32api is not found:

[Code from platform.py]
# Import the needed APIs
try:
import win32api
except ImportError:
return release,version,csd,ptype
[/Code from platform.py]
Accordingly, my Python 2.3.5 final which has win32api installed can get
the platform answer right:

$ /py23/python/dist/src/MinGW/python -i
Python 2.3.5 (#62, Feb 12 2005, 02:56:20)
[GCC 3.4.2 (mingw-special)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import platform
print platform.system(), platform.release() Windows 98
But where I don't have win32api installed, my Python does not know that
answer you seek:
$ /py25/python/dist/src/MinGW/python -i
Python 2.5a0 (#65, Apr 12 2005, 20:22:54)
[GCC 3.4.2 (mingw-special)] on win32
Type "help", "copyright", "credits" or "license" for more information. import platform
print platform.system(), platform.release() Windows


Regards,
Khalid

Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: stewart.midwinter | last post by:
No doubt I've overlooked something obvious, but here goes: Let's say I assign a value to a var, e.g.: myPlace = 'right here' myTime = 'right now' Now let's say I want to print out the two...
2
by: Ravi | last post by:
My XML looks like: <abc> <def type="apple"> 1 </def> <def type="peach"> 2 </def> <def type="orange"> 3 </def> <def type="banana"> 4 </def> <def type="plum"> 5 </def> </abc>
1
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML:...
21
by: TheKeith | last post by:
I heard that the name attribute is deprecated in html 4.01 strict. Is it recommended that you use the ID attribute for images along with the getElementById method instead of the old way? Thanks.
12
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" ...
11
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html>...
3
by: jparulan | last post by:
Hi All, I'm using SOAP3.0. I was able to successfully call a WSDL file and get a value properly. But when the WSDL changed to have a MULTIPLE <element name> it was failing. This code works...
1
by: ivanet | last post by:
Hello everyone, I am trying to use the following Schema but I get the error "src- resolve: Cannot resolve the name 'ValuesList' to a(n) 'element declaration' component." at line 144. I have...
2
by: pythonnewb | last post by:
I am fairly new to programming but have some very basic Java background. I am just learning python and tried to make a module that would allow me to create a file containing an address book. I was...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.