Physical constants

Jean-Paul Calderone exarkun at divmod.com
Sat Nov 4 03:49:26 CET 2006


On Fri, 3 Nov 2006 18:57:49 -0500, Tommy Grav <tgrav at mac.com> wrote:
>I have some code for doing orbital computations. The code is kind of
>extensive with many classes, each having several functions. In these
>functions I need to use constants (like the gravitational constant).
>What is the best way of implementing a solution when constants are
>used in several different classes and functions? I do not want to
>pass the constant down through the functions. I have thought of
>making a class of constants but I do not want to invoke an
>instant in each function. How is the pi and e constants in math
>coded?

FWIW,

http://twistedmatrix.com/trac/browser/sandbox/exarkun/physics/point.py

Are you working on something similarly general?  I'd be interested to
take a look at your code if so.  In my spare time I'm working on some
simulation code that would probably benefit from something more correct
than what's at the above URL.

Jean-Paul



More information about the Python-list mailing list