Modifying the value of a float-like object

Steven D'Aprano steven at
Wed Apr 15 05:35:14 CEST 2009

On Tue, 14 Apr 2009 06:03:58 -0700, Eric.Le.Bigot wrote:

> Hello,
> Is there a way to easily build an object that behaves exactly like a
> float, but whose value can be changed?

Yes, have a look at the source code for UserString.MutableString for some 

> 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.

Why is that the goal? If you want to change the value of x, just change 
the value of x.


More information about the Python-list mailing list