T
Tuure Laurinolli
Some time ago I was playing with the idea of using an actual IDE to
write my python code. I first played with IDLE, but noticed that it was
kind of limited and for some reason it worked extremely slowly when
started from a shortcut on desktop(not so when started from shortcut in
start menu).
Then I tried Pythonwin and noticed that it didn't provide any
indentation help at all - to my surprise. I discarded the idea of using
it, but for some reason tried it again later - only to find indentation
working just fine.
A bit of research revealed that the problem was caused by opening a file
residing on a network drive. How strange.
Some more research and the problem became apparent. When python opened
the file and windows code took over python code, it silently changed the
locale to "the right locale", which happens to use , as decimal
delimiter instead of the "standard" . So when pythonwin(or IDLE, they
use the same indentation code) tried to convert a string into float into
int in order to find the line I was on(strange Tkinter stuff), it
promptly raised an exception because "19.3" obviously wasn't a float -
it contained strange characters!
A dive into python source shows that when python locale is normally set
through appropriate module, it preserves the LC_NUMEERIC locale as the
standard C to ensure correct handling of floating point values and only
sets the user-defined locale for the module-specific functions that
actually make use of it(and resets it back to C-locale whenever user
changes the locale).
Also, Pythonwin and IDLE must use some truly wondrous way to open files
which triggers this behavior, standard open() didn't change anything.
Forgive any mad-rambling-like qualities of this post, It's late (or
early, if you will), and I'm nearly asleep already.
write my python code. I first played with IDLE, but noticed that it was
kind of limited and for some reason it worked extremely slowly when
started from a shortcut on desktop(not so when started from shortcut in
start menu).
Then I tried Pythonwin and noticed that it didn't provide any
indentation help at all - to my surprise. I discarded the idea of using
it, but for some reason tried it again later - only to find indentation
working just fine.
A bit of research revealed that the problem was caused by opening a file
residing on a network drive. How strange.
Some more research and the problem became apparent. When python opened
the file and windows code took over python code, it silently changed the
locale to "the right locale", which happens to use , as decimal
delimiter instead of the "standard" . So when pythonwin(or IDLE, they
use the same indentation code) tried to convert a string into float into
int in order to find the line I was on(strange Tkinter stuff), it
promptly raised an exception because "19.3" obviously wasn't a float -
it contained strange characters!
A dive into python source shows that when python locale is normally set
through appropriate module, it preserves the LC_NUMEERIC locale as the
standard C to ensure correct handling of floating point values and only
sets the user-defined locale for the module-specific functions that
actually make use of it(and resets it back to C-locale whenever user
changes the locale).
Also, Pythonwin and IDLE must use some truly wondrous way to open files
which triggers this behavior, standard open() didn't change anything.
Forgive any mad-rambling-like qualities of this post, It's late (or
early, if you will), and I'm nearly asleep already.