[python-win32] pb with string conversion to float and GetObject call

popov pythonwin at evpopov.com
Wed Sep 10 17:40:49 EDT 2003


Ok, thanks for the test.
I can explain the difference in behaviour: I think you have '.' as the
decimal symbol for numbers in your regional settings. I have ','. Indeed, if
I change it to '.', it works. But I think it's not a solution: I would like
to keep ',' as the decimal point AND have the code working.

I think an explanation of the behaviour is that in the chain call initiated
by the GetObject call from python, some code modify the local settings used
by the current thread to make it use the settings set at the computer level,
and not the settings that the python interpreter may have defined itself...
So, when the call get back to python, the local settings now say that the
decimal point is ',' on my computer, which make the conversion from '8.4' to
float fail.

----- Original Message ----- 
From: "Jim Vickroy" <Jim.Vickroy at noaa.gov>
To: "popov" <pythonwin at evpopov.com>
Cc: <python-win32 at python.org>
Sent: Wednesday, September 10, 2003 4:21 PM
Subject: Re: [python-win32] pb with string conversion to float and GetObject
call


> Hmm ... I can not duplicate this behavior on my Win 2k Professional
system:
>
>
> PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on
win32.
>
> Portions Copyright 1994-2001 Mark Hammond (mhammond at skippinet.com.au) -
see
> 'Help/About PythonWin' for further copyright information.
> >>>
> >>> print float('8.4')
> 8.4
> >>> import win32com.client
> >>> print float('8.4')
> 8.4
> >>> obj = win32com.client.GetObject ("winmgmts:")
> >>> print float('8.4')
> 8.4
> >>>
>
>
>
> popov wrote:
>
> > Here's a strange one:
> >
> > print float('8.4')
> >
> > Works as expected.
> > But:
> >
> > import win32com.client
> > obj = win32com.client.GetObject ("winmgmts:")
> > print float('8.4')
> >
> > Throws a 'ValueError: invalid literal for float(): 8.4' exception on the
> > print line !
> > If you use '8,4' instead of '8.4', then it works (!). So it seems that
some
> > locals have been modified here by the call to GetObject (without this
call -
> > leaving only the import statement - the problem does not show up).
> > Note that using 'LDAP:' instead of 'winmgmts:', everything is ok. So
maybe
> > the culprit is the winmgmts provider...
> > If someone could test this and let me know the results. Thx
> >
> > My system: W2k Server english, python 2.3, pywin32 for python 2.3.
> >
> > _______________________________________________
> > Python-win32 mailing list
> > Python-win32 at python.org
> > http://mail.python.org/mailman/listinfo/python-win32
>
>




More information about the Python-win32 mailing list