Modifying the value of a float-like object

Suraj Barkale suraj at barkale.com
Wed Apr 15 13:12:17 EDT 2009


 <Eric.Le.Bigot <at> spectro.jussieu.fr> writes:
> 
> Hello,
> 
> Is there a way to easily build an object that behaves exactly like a
> float, but whose value can be changed?  The goal is to maintain a list
> [x, y,…] of these float-like objects, and to modify their value on the
> fly (with something like x.value = 3.14) so that any expression like "x
> +y" uses the new value.
> 

Have you looked at sympy (http://code.google.com/p/sympy/)? It implements
symbolic mathematics so you can define the equations & put in the values to get
the result. You should be able to derive from the Symbol class to implement the
accuracy behavior.

Regards,
Suraj




More information about the Python-list mailing list