[python-win32] win32dph.EnumObjectItems problem

Frank Guenther xeoicq at netscape.net
Wed Apr 6 09:16:08 CEST 2005


"""

Hi All,

I have a problem using win32pdh with Python22.
The call of win32pdh.EnumObjectItems changes the
decimal point from . to , on my system.
I think it could be a problem with the language setting
form german.
So I run in trouble with unpickle of float objects.
Is there a soulution or workaround?

The problem occurs under german language setting
for windows.
For german EnumObjectItems neede 'Prozess' insted of 'Process'
to work.
"""

import pickle

def pickle_and_unpickle(to_pickle):
    pickled = pickle.dumps(to_pickle)
    print "%s -> %s"%(to_pickle, pickled)
    return pickled

float_obj = 1.2345

str_float_obj_before = str(float_obj)

pickled_before=pickle_and_unpickle(float_obj)

#the trouble begins:
#this commands changes the decimal point from . to , (german language 
setting)
#so the unpickle didn't work for pickle done before the calls
import win32pdh
Process="Prozess" #German   Process="Process"   #English
junk, processes = 
win32pdh.EnumObjectItems(None,None,Process,win32pdh.PERF_DETAIL_WIZARD)     
 

str_float_obj_after = str(float_obj)
print "the string representation of float changed from %s to 
%s"%(str_float_obj_before,str_float_obj_after)


pickled_after=pickle_and_unpickle(float_obj)

#this is ok
print pickle.loads(pickled_after)

#error due to comma(,) insted of point (.)
print pickle.loads(pickled_before)


"""

Ciao,
   Frank
"""


More information about the Python-win32 mailing list