T
Tomasz Lisowski
Hi,
We are distributing our Python application as the short main script (.py
file) and a set of modules compiled to the .pyc files. So far, we have
always treated .pyc files as portable between platforms, but recently we
have discovered an annoying problem. In a module, there is the following
code fragment:
Deg2Rad = math.pi/180.0
angleEPS = 0.5
angle0B = angleEPS*Deg2Rad
which calculates 'angle0B' as the angle of a half of a degree, converted
to radians. The module has been compiled on an English Windows XP
machine, and then tested on a Polish Windows XP workstation.
What was our astonishment, when various exceptions started to be raised
on a test machine (no problem on the original English-version Windows
XP). We have traced them to the fact, that both angleEPS and angle0B
were found to be ZERO (!!!), whereas in reality, angle0B is about 0.008.
And this all happened silently, without any error during the import of
the module!
What's the reason of this error? I start thinking, that it may be
related to the fact, that the decimal point on the Enlish Windows XP is
the '.' character, and on the Polish one - ','.
Is there a good method to avoid this kind of problems? How to make such
distributed modules really portable?
Thanks in advance
We are distributing our Python application as the short main script (.py
file) and a set of modules compiled to the .pyc files. So far, we have
always treated .pyc files as portable between platforms, but recently we
have discovered an annoying problem. In a module, there is the following
code fragment:
Deg2Rad = math.pi/180.0
angleEPS = 0.5
angle0B = angleEPS*Deg2Rad
which calculates 'angle0B' as the angle of a half of a degree, converted
to radians. The module has been compiled on an English Windows XP
machine, and then tested on a Polish Windows XP workstation.
What was our astonishment, when various exceptions started to be raised
on a test machine (no problem on the original English-version Windows
XP). We have traced them to the fact, that both angleEPS and angle0B
were found to be ZERO (!!!), whereas in reality, angle0B is about 0.008.
And this all happened silently, without any error during the import of
the module!
What's the reason of this error? I start thinking, that it may be
related to the fact, that the decimal point on the Enlish Windows XP is
the '.' character, and on the Polish one - ','.
Is there a good method to avoid this kind of problems? How to make such
distributed modules really portable?
Thanks in advance