A stupid newbie question about output...

J dreadpiratejeff at gmail.com
Tue Oct 20 20:23:09 CEST 2009


Can someone explain why this code results in two different outputs?

> for os in comp.CIM_OperatingSystem ():
>  print os.Name.split("|")[0] + " Service Pack", os.ServicePackMajorVersion
>  osVer = os.Name.split("|")[0] + " Service Pack", os.ServicePackMajorVersion
>  print osVer

the first print statement gives me this:
  Microsoft Windows XP Professional Service Pack 3

and the second print statement gives me this:
(u'Microsoft Windows XP Professional Service Pack', 3)

I know this is a grossly oversimplified example.

The ultimate goal is to get certain things from the system via WMI and
then use that data in other scripts to generate test case scripts for
a testing tool.

So given this example, what I ultimately want is to create a class
full of this stuff, that I can call from another program like this:

> import SystemInformation

> comp = SystemInformation()

> # Get OS info
> OSVersion = comp.osVer

OR just print the result

> print comp.osVer

Can this be cleared up by using some sort of formatting in print (like
sprintf) or am I going to have to manipulate the WMI results before
sending them out??

Thanks

Jeff

-- 

Ted Turner  - "Sports is like a war without the killing." -
http://www.brainyquote.com/quotes/authors/t/ted_turner.html



More information about the Python-list mailing list