Steven D'Aprano wrote:
<snip>
Oh nonsense. Many programming languages have mutable floats.
That's irrelevant. Python doesn't. So introducing one will quite
likely alter the OP's code's behavior. It doesn't matter if it's
possible, it matters whether the existing code's behavior might change,
and of course if a future maintainer might have trouble making sense of
it.
What are you talking about? Python introduces new types quite frequently.
We now have sets, frozensets, rationals, decimals and namedtuples, and
we'll soon be getting ordereddicts and probably others as well. People
create new types in their code *all the time*, using the class statement.
If the OP wants to create a MutableFloat type, that's his prerogative.
The OP has existing code, and apparently a good deal of it, which he
wants to run unchanged. That's the whole purpose behind the
discussion. All I've been asserting is that changing the variables
that used to be floats to some new mutable-type would be risky to his
code. Since he's willing to assume the risk, then he can use the code
which I proposed. I'd much rather point out the risks, than have
somebody paste something in and assume it'll work like before.
We'd better skip the discussion of other languages, since you're mixing
terminology something awful.
--
http://mail.python.org/mailman/listinfo/python-list