"""

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
"""
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to